-->
Page 1 of 1

Experimenting with ESp-01, Arduino and Thingspeak

PostPosted: Sat Jun 18, 2016 9:16 am
by NeilCee88
Hi all,
Being a NOOB I realise this may be junk info, but it was my 'ah-ha' moment and I thought it may be of help to others starting out on this journey.
Anyway, to set the scene, I'm running 2 Arduinos connected via esp8266-01's - 1 sending temp readings from an analog MCP9700 sensor to Thingspeak (field 1), and the other reading from Thingspeak (field 2) checking the output value in the range from 0 - 7 , setting coulrs of RGB Leds accordingly.
Anyway my moment of enlightenment came when, after struggling with READTS and SENDTS for a few weeeks, it hit me that the data to and from Thingspeak is in string format..so I altered my code and now I have another ESP-01 running code to text my phone , upload to thingspeak and check temperature reading.
Thank you for your patience , my humble code is below if anyone wishes to use parts of it....

print "****************"
print "Date is: " & time("day / month / year...hour:min:sec")
print "Local IP is: " & ip()
po 2 1
print "Sending Alert"
print 'wget("maker.ifttt.com/trigger/front_door/with/key/API WRITE KEY")
po 2 0
print "****************"
print "sending colour request to thingspeak"
v = str(3)
print "Colour: " & v
f = str(2)
print "Field : " & f
sendts("THINGSPEAK API WRITE KEY",f,v)
print "****************"
print "sending temperature request to thingspeak"
g = str(90636)
w = str(1)
print "Latest temperature reading is: " & readts("THINGSPEAK API READ KEY",g,w)
print "****************"
print "Flashing on the way to sleep"
led = 0
Do
led = led + 1
po 2 1
delay 500
po 2 0
delay 500
loop until led > 9
po 2 0
led = 0
print
Button "LED OFF" [led_off]
print
print
Button "LED ON" [led_on]
print
print
Button "REBOOT" [reboot]
print

'Sleep 0

[led_on]
po 2 1
v = str(3)
f = str(2)
sendts("THINGSPEAK API WRITE KEY",f,v)

wait

[led_off]
po 2 0
v = str(0)
f = str(2)
sendts("THINGSPEAK API WRITE KEY",f,v)
wait

[reboot]
reboot
wait