Skip to content

Part 3. Getting Fancy

Rachel edited this page Sep 20, 2017 · 2 revisions

The most fun part of any project is actually making it yours. So let's go through how you can edit the sketches we ran to stream what you want!

Send multiple device readings to the same bucket

This code is found in the vicinity of lines 22-30 under the “Initial State Streamer” section:

screen shot 2015-11-09 at 12 52 25 pm

If you want all of your different devices to send their data to the same Initial State bucket, just make sure that this bucketKey is the same across all of them.

So something like “Living_Room” would be perfect for all of the sensors in your living room! Or you could call them all “Home” and name the individual signals by room. That’s covered further down.

Just remember that the bucket key and signal names can't contain spaces!

Change how many signals you're sending

This code is found around lines 33-43 under the “Event Signal Settings” section:

screen shot 2015-11-09 at 1 02 35 pm

If you want to, say, send only Temperature and Humidity, and not Heat Index, you would need to change this number to 2. Same goes for adding more signals.

Change the name of your signals

This code is found around lines 33-43 under the “Event Signal Settings” section:

screen shot 2015-11-09 at 1 02 35 pm2

This is where you can change your signalName to something like “Kitchen_Temp” or “Someone_is_Home”. You can add an emoji, too, so long as there are no spaces between it and any other words you add (ie. “:wave:Motion”). You can find a list of emoji codes here: http://emoji.codes/

The order of names matters - they correspond to what number of the signalData array you are assigning your sensor reading. More on that below.

Change the data you're sending

This code is found around lines 161-187 under the “Read from the sensor” section:

screen shot 2015-11-09 at 1 15 21 pm copy

In the temperature/humidity sensor example, we have created a function called “takeTempHum()”. Inside of this function we read from the sensor and then assign those sensor values to our signalData array. Arrays start counting at 0. The function is executed inside of the loop().

You can see on lines 166, 168, and 170 that we are using the DHT library to read different values from the sensor. We are then assigning those values to letters - h for humidity, t for temperature, and f for temperature in Fahrenheit. On line 181 we are assigning heat index to hif.

Data values can also be emojis. You can find a list of emoji codes here: http://emoji.codes/

Starting on line 184, we are placing these readings into the signalData array. Whatever you put in the signalData array must be a String, so make sure to keep your readings inside String(). The number is also important because this corresponds to the signalNames order, so make sure that they match!

One way you could switch this section up would be to send temperature in Celsius too (we’re already reading it on line 168). You could just change signalData[0] = String(f) to signalData[0] = String(t).

You can adjust this code for whatever you might have your Cactus Micro doing, like watching for movement or tracking range!

<< Part 3: Send Sensor Data - Part 4: Troubleshooting the Connection >>

Clone this wiki locally