TinyCircuits

Communicating wtih Wirelings

Communicating wtih Wirelings
« on: January 13, 2020, 08:46:58 PM »
How do you communicate with a Wireling module?

 I know it's I2C protocol and the library is probably <Wire.h> but what are the commands to do so?

For example, using a Wireling Adapter Shield connected to a TinyScreen+, how do you get information from a Moisture Sensor into Arduino code?  Are there addresses involved?  etc, etc.

Can you point me to a page(s) on the website that has this info?

Thanks,
John


Re: Communicating wtih Wirelings
« Reply #1 on: January 14, 2020, 12:46:03 PM »
Each Wireling has example code that you can test with your Arduino IDE. For example, the 0.42" OLED Wireling has two Download files with:

* Arduino Sample Code
* Arduino library

https://tinycircuits.com/collections/wirelings/products/0-42-oled-screen-wireling

Once you've gotten comfortable with the Moisture Sensor and Display examples, you'll run into another question, which is how to display the data from your moisture sensor. As you've noticed, Wirelings use I2C. Each Wireling has its own I2C address. To talk to a Wireling you typically set the I2C port:

   Wireling.selectPort(portForMoistureSensor);
   // read data
   Wireling.selectPort(portForDisplay);
   // write data to display

That's a simple example.

As your project grows, you'll start adding more Wirelings. Yay! Wirelings are fun!
I've got three Wirelings hooked up to my TinyZero via the Wireling I2C Adapter Shield.
I'd add a fourth, but the USB micro plug gets in the way (sadness).

I look forward to seeing your project. I'm guessing you're doing a gardening project and I'd love to see it!

« Last Edit: January 14, 2020, 12:55:04 PM by karl_lew »

Re: Communicating wtih Wirelings
« Reply #2 on: January 14, 2020, 02:21:20 PM »
Hello all,

Karl is right! There is sample code for all TinyCircuits products available. Formal tutorials are being written as the support for Wirelings ramps up, but in the meantime, there may be some working example programs available on the TinyCircuits GitHub. I will say, however, that it might be more helpful to wait until there is official support so you don't end up downloading an old program version. Official support will be documented and encapsulated in a Learn Page tutorial, so that's the easiest way to tell if a program is ready to use.

To try and answer your question the most document-y way, all Wirelings use the Wireling.h library that includes some basic helper functions to help you enable power with the .begin() function, and select the port of whatever adapter board or processor you're using. So most Wireling examples start out like this:

#include <Wireling.h>

setup() {
   Wireling.begin();
   Wireling.selectPort(wirelingPort);
   ....
}

For a more direct solution, here is the Learn Page for the Soil Moisture Wireling that includes example code: https://learn.tinycircuits.com/Wirelings/Soil-Moisture_Wireling_Tutorial/

And here is a Learn Page for the Wireling Adapter TinyShield: https://learn.tinycircuits.com/Wirelings/Wireling-Adapter_TinyShield_Tutorial/

I'm not sure what Wireling Kit you bought, but there should be a Kit page to get you started with for most, for example, here is the Planty Kit: https://learn.tinycircuits.com/Wirelings/Wireling_Planty_Kit_Tutorial/

Hope that helps!
Réna

Re: Communicating wtih Wirelings
« Reply #3 on: January 14, 2020, 04:04:57 PM »
All,

Thanks for all your help on the Wireling subject!

I'll check out each of your references.

Thanks again,

John