loading

This is a simple demo using the ESP8266 and Cactus Micro (a arduino compatible board) to update a remote server (https://data.sparkfun.com/) using a digital temperature sensor.

Step 1: Materials

The Cactus Micro is an arduino compatible dev board, it integrated a WIFI chip ESP8266.

Step 2: Connecting the Wires Together

  • Connect esp8266 module is easy. Just plug in to the pins.
  • DS18B20 - DQ(2) -> Cactus pin 14, DQ(2) -> 4.7KR -> VCC(3.3V)

Step 3: Arduino Setup and Sketch

The sketch code: https://github.com/AprilBrother/cactus-micro/blob/...

For Cactus Micro Rev2, the default firmware for esp8266 is espduino. Please use this sketch instead. https://github.com/AprilBrother/cactus-micro-r2/tree/master/libraries/CactusMicro/examples/temperatureLogger

Step 4: SparkFun Setup

We create a data stream at SparkFun, follow this link to do this. https://data.sparkfun.com/streams/make

Once you've created your stream, keep the window open so you have easy access to your public and private keys handy - you'll need those to replace the KEY in the Arduino sketch.

Now you are ready to start sending data.

<p>hi,</p><p>could you update the code for cactus micro rev2 please?</p><p>trying, but i can not.</p><p>question: how long data keeps on sparkfun? (the free one)</p>
<p>Hi, We've updated the sketch for Cactus Micro Rev2 today. It should work with default esp8266 espduino firmware.</p><p>https://github.com/AprilBrother/cactus-micro-r2/tree/master/libraries/CactusMicro/examples/temperatureLogger</p>
<p>Can you make it reading temperature from several sensors? Should it be like example below or there is better way? Thanks.</p><p>tempSenNum++;</p><p>if (tempSenNum &gt; 3){</p><p>tempSenNum = 1;</p><p>}</p><p>switch (tempSenNum) {</p><p>case 1:</p><p> DeviceAddress thermometer = { xxxxxxxxxxxxxxxxxxxxx }; //sensor #1</p><p> break;</p><p> case 2:</p><p> DeviceAddress thermometer = { xxxxxxxxxxxxxxxxxxxxx }; //sensor #2</p><p> break;</p><p> case 3:</p><p> DeviceAddress thermometer = { xxxxxxxxxxxxxxxxxxxxx }; //sensor #3</p><p> break;</p><p>}</p>
<p>My order from Tindie arrived... ready to build... but link for code not there...</p><p>https://github.com/AprilBrother/cactus-micro/blob/master/examples/arduino/temperatureLogger/temperatureLogger.ino</p>
<p>Hi,</p><p>I have just updated the link for the sketch. </p><p>Please note: the code is only work on rev1. You must change the code to hardware serial port Serial1.</p>
<p>Hi there,</p><p>I'm interested in using this Cactus micro in my project for sending data to a website.</p><p>Do the flash memory,ram and ROM stack when I use it with Arduino Uno? Or any different in term of speed?</p><p>Thank you</p>
<p>You should compare it with Arduino Leonardo or Arduino Micro. The micro controller is ATMega32U4.</p>
<p>it's coming along yanc, look how cool the cactus micro look inside the plant pot..</p><p><a href="https://www.instructables.com/id/the-plant-pot/step1" rel="nofollow">https://www.instructables.com/id/the-plant-pot/step...</a></p>
<p>It looks great! I </p>
<p>I made some change with your code. Not tested. I replace some &quot;Serial&quot; with the SoftwareSerial port &quot;debug&quot;. Please diff the code.</p><p>https://gist.github.com/volca/da178cd000abb91d649f</p>
<p>i copied your code above and using IDE 1.0.6 now - still no online upload, also the temperature is really high all the time, very strange.</p><p>.</p><p>still never AT+CWMODE=1 or AT+CWJAP lines shown on the serial monitor;</p><p>temperature1021</p><p>light256</p><p>water53</p><p>AT+CIPSTART=&quot;TCP&quot;,&quot;184.106.153.149&quot;,80</p><p>AT+CIPCLOSE</p><p>temperature1022</p><p>light252</p><p>water33</p><p>AT+CIPSTART=&quot;TCP&quot;,&quot;184.106.153.149&quot;,80</p><p>AT+CIPCLOSE</p><p>.</p><p>i still think it is the code, rgb led works with the right colors and sensors are picking up data as well. just no online connection</p>
<p>For test WIFI connection, please make it simple. Run the sketch below.</p><p>https://gist.github.com/volca/69c559cfb50e5580668c</p>
<p>Module Test: OK</p><p>AT+CWJAP=&quot;8d59bb&quot;,&quot;244221619&quot;</p><p>....................Can not connect to the WiFi.</p><p>Module Test: OK</p><p>AT+CWJAP=&quot;8d59bb&quot;,&quot;244221619&quot;</p><p>....................Can not connect to the WiFi.</p><p>Module Test: OK</p><p>AT+CWJAP=&quot;8d59bb&quot;,&quot;244221619&quot;</p><p>....................Can not connect to the WiFi.</p><p>Module Test: OK</p><p>AT+CWJAP=&quot;8d59bb&quot;,&quot;244221619&quot;</p><p>....</p><p>keeps repeating this. isn't it supposed to first set the mode, AT+CWMODE=1 ? this line doesn't showup on the software serial monitor..</p>
<p>I edited the line 31:</p><p>Original:</p><p> delay(500);//delay after mode change <br></p><p>Edited:</p><p>delay(3000);//delay after mode change <br></p><p>Give it enough time. It will connect the WIFI easy. I just tested the sketch and it worked.</p>
<p>Module Test: OK</p><p>AT+CWJAP=&quot;8xxxxxb&quot;,&quot;2xxxxxx9&quot;</p><p>.....OK, Connected to WiFi.</p><p>.</p><p>yes it did work.!! now how can we add in the sensors and leds like here;</p><p><a href="https://drive.google.com/file/d/0B8bvYGugxvFFYjJoNlBmUTFCN1k/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B8bvYGugxvFFYjJoN...</a></p><p>.</p><p>thank you so very much once again..!!!</p>
<p>I replaced the function connectWIFI in the previous sketch. Please have a try.</p><p><a href="https://gist.github.com/volca/da178cd000abb91d649f" rel="nofollow">https://gist.github.com/volca/da178cd000abb91d649f</a></p>
<p>actually i think i solved the problem.</p><p>on the serial monitor the code never prints - debug.println(&quot;AT+CWMODE=1&quot;);</p><p>this maybe why, </p><p>-</p><p>Module Test: OK</p><p>AT+CWJAP=&quot;8xxxb&quot;,&quot;2xxxx9&quot;</p><p>.....OK, Connected to WiFi.</p><p>temperature1019</p><p>light481</p><p>water0</p><p>SEND: AT+CIPSTART=&quot;TCP&quot;,&quot;184.106.153.149&quot;,80</p><p>GET /update?key=9TYUWTFXTYC9RKT8&amp;field1=1019&amp;field2=481&amp;field3=0</p>
<p>Change the line </p><p>debug.println(&quot;AT+CWMODE=1&quot;);</p><p>to </p><p>sendDebug(&quot;AT+CWMODE=1&quot;);</p><p>You will see it on the serial monitor. It's not the problem.</p>
<p>how about this,</p><p>on my sketch; <a href="https://drive.google.com/file/d/0B8bvYGugxvFFYjJoNlBmUTFCN1k/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B8bvYGugxvFFYjJoN...</a></p><p>at the very end line, i have; </p><p><em>cmd = &quot;AT+CIPMUX=0&quot;;</em></p><p><em> sendDebug( cmd );</em></p><p><em> if( Serial.find( &quot;Error&quot;) )</em></p><p><em> {</em></p><p><em> debug.print( &quot;RECEIVED: Error&quot; );</em></p><p><em> return false;</em></p><p><em> }</em></p><p>you didn't include above part in your final sketch here; <a href="https://gist.github.com/volca/da178cd000abb91d649f" rel="nofollow" style="">https://gist.github.com/volca/da178cd000abb91d649</a></p><p>i remember reading that this line is very important for successful upload. i tried including it myself but didn't still no success, i'm not sure where exactly it has to go however, maybe you can include it</p><p>.</p><p>also, looking at other esp8266 posts here, i notice that after AT+CIPSTART the monitor prints AT+CIPSEND=(a random number?)</p><p>when I used esp8266 rev-01 on my previous project this is what the serial monitor looked like - picture 1</p><p>picture 2 is how it looks like with your final sketch right now.. thingspeak channel still doesn't receive any data.</p>
<p>I just added the code after line 63. Please have a try. </p>
<p>again, it doesn't compile - this time line 70 is highlighted and it says;</p><p><em>return-false;</em></p><p><em>error: return-statement with a value, in function returning 'void'</em></p><p>.</p><p>感谢您的时间 :)</p>
<p>Ah. I replaced the &quot;return false;&quot; to &quot;return;&quot;. Then everything goes well. I just compile the sketch and success.</p>
<p>yes, it compiled and uploaded to cactus micro, but still no success on thingspeak.com. check out this picture;<br>.<br>everything seems like it is working. what about line &quot;AT+CIPSEND=&quot; what is this random number next to it.? i remember with the esp rev-01 i would get different numbers on the serial monitor when the device worked and didn't work.</p><p>also AT+CIPSTART in our new sketch is different, it shows up as SEND: AT+CIPSTART.. ?</p><p>it connects to wifi, but doesn't upload, maybe it never gets a successful connection with thingspeak.com</p>
<p>I move the code to the link. <a href="https://raw.githubusercontent.com/volca/cactus_micro_trial/master/cactus_micro_trial.ino" rel="nofollow">https://raw.githubusercontent.com/volca/cactus_mic...</a></p><p>I think the cactus micro need a simple library to handle http request. It will be more friendly for newbie. </p>
<p>you did it..!!!! finally uploading successfully :)</p><p>here is the channel; <a href="https://thingspeak.com/channels/18259" rel="nofollow">https://thingspeak.com/channels/18259</a></p><p>this is the cheapest cloud updating, analog sensor, with onboard wifi chip, arduino programmable device in the world right now :) and you did it all - thank you so much yanc.!! i will be making a detailed post soon, i will let you know.. </p><p>.</p><p>what was the problem do you know? also if you can make a library for analog sensors and how to upload them online to thingspeak would be great. because with thingspeak you can connect a twitter account for e-mail updates/alerts or you can set up and app to control AC relays as well, all the cactus micro has to do is to read raw sensor data (no conversions, no libraries) and upload it to thingspeak. the rest can be done on the cloud based on this data.</p><p>.</p><p>also do you work for april brother company.?</p><p>謝謝</p>
<p>Congratulation! It's almost done.</p><p>I have found some simple library for esp8266 and choose one for cactus micro. I'm also waiting for your new plant doctor project.</p><p>Yes. I work at April Brother.</p>
<p>it doesn't compile, line 65 cmd = &quot;AT+CIPMUX=0&quot;; is highlighted and </p><p>'cmd' was not declared in this scope</p>
<p>I made a minor change for line 65. It should be ok.</p>
<p>worked.!!</p><p>Module Test: OK</p><p>AT+CWJAP=&quot;8xxxb&quot;,&quot;2xxxx9&quot;</p><p>.......OK, Connected to WiFi.</p><p>temperature1010</p><p>light456</p><p>water0</p><p>SEND: AT+CIPSTART=&quot;TCP&quot;,&quot;184.106.153.149&quot;,80</p><p>GET /update?key=9TYUWTFXTYC9RKT8&amp;field1=1010&amp;field2=456&amp;field3=0</p><p>temperature1010</p><p>light470</p><p>water0</p><p>SEND: AT+CIPSTART=&quot;TCP&quot;,&quot;184.106.153.149&quot;,80</p><p>GET /update?key=9TYUWTFXTYC9RKT8&amp;field1=1010&amp;field2=470&amp;field3=0</p><p>temperature1010</p><p>light474</p><p>water0</p><p>...</p><p>however thingspeak.com doesn't recieve the numbers.. i will look into that later on. i should be able to fix that myself, if not i'll message you again. <br>.</p><p>i am going to do a detailed instructable soon, i will be promoting your work and cactus micro - will let you know ! </p><p>thank you so much once again</p>
will try and reply in 3hrs
<p>You can upload the serialMonitor sketch to cactus micro. It's good for test AT command via Serial Monitor.</p><p> <a href="https://github.com/AprilBrother/cactus-micro/tree/master/examples/arduino/serialMonitor" rel="nofollow">https://github.com/AprilBrother/cactus-micro/tree/...</a></p><p>Type in the Serial Monitor to test wifi connection</p><p>AT+CWMODE=1</p><p>AT+RST</p><p>AT+CWJAP=&quot;YOUR-SSID&quot;,&quot;YOUR-PASS&quot;</p>
<p>Please use Arduino IDE 1.0.x. Not 1.6.1. </p><p>All the AT command should send to SoftwareSerial _rxpin/txpin not &quot;Serial&quot;. Because the esp8266 is connected to SoftwareSerial pin 11/12.</p><p>What Arduino board did you use early?</p>
<p>i used arduino nano + esp-01, here is my work, it works real well; <a href="https://www.instructables.com/id/Envolysis/" rel="nofollow">https://www.instructables.com/id/Envolysis/</a></p><p>.</p><p>but now we need to update the code for it to work with cactus micro. i have tried but no success; <a href="https://drive.google.com/file/d/0B8bvYGugxvFFYjJoNlBmUTFCN1k/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B8bvYGugxvFFYjJoN...</a></p><p>the code uploads to cactus micro using IDE 1.6.1, lillypad usb chosen. and the sensors work, they read data and turn on the rgb led correct color, no problem there, i just can't upload the data to thingspeak.</p><p>.</p><p>it has to be a code mistake, and most likely smtg to do with the software serial line.</p><p>.</p><p>thank you for your time,</p>
<p>Please try with Arduino 1.0.6. I test under 1.6.1 but have some issues with SoftwareSerial.</p>
<p>I will reply to you 8 hours later because it's too late. Please write your reply here. I will be back.</p>
<p>The code will stuck if the cactus micro not connect to USB. </p><p> if(Serial.find(&quot;OK&quot;))</p><p> {</p><p> debug.println(&quot;RECEIVED: OK\nData ready to sent!&quot;);</p><p> connectWiFi();</p><p> }</p><p>Dont use &quot;Serial&quot; for atmega32u4 when it havent connect to usb. I will give you a link from arduino.cc to describe it. </p><p><a href="http://arduino.cc/en/Guide/ArduinoLeonardoMicro#toc4" rel="nofollow">http://arduino.cc/en/Guide/ArduinoLeonardoMicro#to...</a></p><p>For instead, you can use the Serial1.</p>
by the way cactus micro was connected to computer usb earlier
<p>The SDK 0.9.5 for esp8266 support light sleep and deep sleep. But it need GPIO15 connect to RST and esp-11 module have no the pin GPIO15. So there's a way that set pin 13 of cactus to low to disable the esp-11. It will save power cosumption.</p>
<p>what if we just put the entire cactus micro board on sleep mode, instead of just the esp chip.? is this possible, would it be easier and more battery life.?</p>
<p>Here's a Sleep library to power saving for atmega32u4.</p><p><a href="https://github.com/n0m1/Sleep_n0m1" rel="nofollow">https://github.com/n0m1/Sleep_n0m1</a></p><p>You can found more examples at Github. </p><p>For esp-11 module, we need make a jump wire to use deep sleep function.</p>
<p>can you confirm my wiring? i can't be sure, ur picture is a little blurry.. my cactus micro is still on the way. it's been 18 days, should be arriving soon :)<br>i will be asking you a few detailed questions once everything is plugged in and ready to go. i'm working on a printed case at the moment.</p>
<p>Yes. You're right. I will make a clear photo later.</p>
<p>Regarding your sketch: Note that Serial.find() is a consuming search; it reads the data from the serial buffer such that it can't be read again. So when you do mySerial.find(&quot;OK&quot;), you can't then do mySerial.find(&quot;ERROR&quot;). Search for one or the other, not both.</p>
<p>Thank you! I've removed the code mySerial.find(&quot;ERROR&quot;)</p>
<p>Out of interest, what's the battery life like for this project?</p>
<p>It can run 24 hours+ with a 1000 mAh battery. The battery life will be longer if I optimize the upload time interval and enable sleep mode for esp8266.</p>
<p>i've just ordered a cactus micro thanks to you. i was waiting for <a href="http://thenextweb.com/insider/2014/11/12/spark-photon-19-kit-building-wi-fi-enabled-products/" rel="nofollow">spark photon</a> to come out in march, but this is cheaper and smaller and better probably right :) great work, follow + favorite.</p>
<p>Thanks. I will be glad to see your new project.</p>
<p>Cool. Thanks for sharing!</p>

About This Instructable

21,268views

81favorites

License:

More by yanc:Siri HomeKit Controlled ESP8266 Lock BLE Rainbow LAMP Arduino BLE Temperature/Humidity logger with DHT11 and iOS display 
Add instructable to: