Tim Kendal in MATLAB Answers
최근 활동: 2021년 9월 24일

Since submitting my query below, I have run my code overnight and found that the data is in fact being uploaded corectly. It now shows in my channel. So my main problem has gone away. The remaining problem is in these lines of code which should print the response from Thingspeak in the console: print(str(response.status) + " " + str(response.reason) + " " + str(timenow) + " " + str(mBars)) #+ " " + str(temp)) print("\n") data = response.read() print(data) conn.close() except: print("connection failed") In short, the line conn.request("POST", "/update", params, headers) works, but lines relating to the response do not. This problem did not arise in my first Channel, mentioned below, where the response in the console is like this: 200 OK 2021-09-24 10:24:25 Any suggestions or help gratefully received! Thanks for looking at this. *********************************** Original post: I have successfully created my first Thingspeak channel and uploaded Mbar data (1 variable). This worked fine. This is the upload function that works - Python3 on my Raspberry Pi. def uploadData(pressure, cTemp): #upload to Thingspeak.com #ctemp is not used mBar = pressure timenow = datetime.now().strftime('%Y-%m-%d %H:%M:%S') params = urllib.parse.urlencode({'field1': mBar, 'key':key }) headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept": "text/plain"} conn = http.client.HTTPConnection("api.thingspeak.com:80") try: conn.request("POST", "/update", params, headers) response = conn.getresponse() #print(mBar) print(str(response.status) + " " + str(response.reason) + " " + str(timenow) + " " + str(mBar)) #+ " " + str(temp)) #print("\n") data = response.read() conn.close() except: print("connection failed") I am now trying to upload to a new Channel I've created, with 4 variables, all from a BM688 Sensor, and get a "connection faiiled" error every time the code calls the Upload function. The reast of the code works fine, displaying all 4 variables in the Console, and also saving the data to a csv file. This is the upload function that does NOT work: def uploadData(temperature, pressure, humidity, air_quality_score): #upload to Thingspeak.com Mbars = pressure timenow = datetime.now().strftime('%Y-%m-%d %H:%M:%S') params = urllib.parse.urlencode({'field1': temperature, 'field2': Mbars,'field3': humidity,'field4': air_quality_score,'key':key }) headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept": "text/plain"} conn = http.client.HTTPConnection("api.thingspeak.com:80") try: conn.request("POST", "/update", params, headers) response = conn.getresponse() #print(mBar) print(str(response.status) + " " + str(response.reason) + " " + str(timenow) + " " + str(mBars)) #+ " " + str(temp)) #print("\n") data = response.read() conn.close() except: print("connection failed") I'm not certain the params line of code is correct, but it does not generate any syntax errors, so I think it should be ok. I did try changing the params line to just 1 variable, but that did not work either. The API key I'm using is correct. Can someone try to point me in the right direction to find what is wrong please! I would be very grateful! Tim Kendal
Christopher Stapels in Discussions
최근 활동: 2021년 2월 7일

I'm presently working on an Air Quality monitor to be able to check the status of my environment and remote environments on ThingSpeak. I was planning on using the BME680 sensor. Does anyone have any experience with this or other air quality sensors? I'm looking probably for CO2 and the like (Volatile Organics), not so much particle sensors, though a combination may be best. What's your favorite air quality sensor? Every low-cost air quality sensor I come across is particle based. If you find a cheap CO2 sensor, I would be interested. CO2 is an important indicator of indoor air quality. Laboratory grade CO2 sensors cost around $50 or so. There are "equivalent" CO2 sensors based on the SGP30 that cost in the $15-20 range. I use ccs811 which needs I2C clock stretching and thus works well with Arduino like boards. It collects VTOC data and calculates eCO2. Great, thanks for sharing air quality environmental sensor thingspeak iot bme680
Ernesto Gutiérrez Rodríguez in MATLAB Answers
최근 활동: 2021년 2월 1일

Hello everybody! I´m a newbee trying to upload data from a MHZ-19B (CO2) sensor and BMP280 (Temperature Higro and Pressure) to Thingspeak. I use ESP EASY in a Lolin Wemos D1 Pro mini My problem is when I read data of my sensors in serial port everthing seems coherent no high value changes between readings, but in my Thingspeak Channel there are very unstable values, you can see here: https://thingspeak.com/channels/1291611 Any help will be great! Thanks in advance Best regards Ernest
Quoc-Khanh Pham in MATLAB Answers
최근 활동: 2020년 9월 28일

I have recently installed an NCD MegaModem paired with an NCD Temperature sensor for our lab freezers (-80c). I have set the gateway for MQTT transmissions. I can see that my MQTT gateway is transmitting data to mqtt… ….com:1883 since I am getting the following output: {"channel":{"id":1155233,"name":"baolab","latitude":"0.0","longitude":"0.0","field1":"temperature_celsius","created_at":"2020-09-23T15:38:10Z","updated_at":"2020-09-23T22:07:26Z","last_entry_id":7982},"feeds":[{… …"created_at":"2020-09-25T17:13:36Z","entry_id":7981,"field1":"{"transmission_count":105,"battery_level":3.06544,"type":39,"node_id":0,"rssi":34,"temperature_celsius":-80.18}"},{"created_at":… …"2020-09-25T17:13:58Z","entry_id":7982,"field1":"{"transmission_count":107,"battery_level":3.06544,"type":39,"node_id":0,"rssi":31,"temperature_celsius":-80.08}"}]} My question is… …: How can I select/choose to show only temperature_celsius on the graph? Right now I am not getting anything on the graphs. Field1 name is temperature_celsius. Thanks a lot!
Vinicio Moya in MATLAB Answers
최근 활동: 2020년 6월 20일

Hello everybody! I want to use a Raspberry Pi 3B+ to control a biorreactor. I have some sensors, and they give me data in an URL (http://plaato.blynk.cc/auth_token/get/pin). How can I make a call to thar URL in Simulink? I don´t want to use ThingSpeak, and I´m sure that Simulink could do this in a simple way. Could yo help me?
JozsV in MATLAB Answers
최근 활동: 2020년 2월 23일

Hello! I'm using this simple code to send data to ThinkSpeak (ESP8266): GET /update?key=xxxxxxxxxxxxxxxx&field1=025.0 It's working fine, no problem. How can I send "sensor error" message to ThingSpeak? For example, the measured temeprature is out of range, unable to get temeprature data from the sensor etc. I would like to see errors in the graph, like in the attached picture. Is it possible? Thank you!
Jayanth Tadikonda in MATLAB Answers
최근 활동: 2020년 2월 20일

#!/usr/bin/python import smbus import math import requests import json power_mgmt_1 = 0x6b power_mgmt_2 = 0x6c def read_byte(reg): return bus.read_byte_data(address, reg) def read_word(reg): h = bus.read_byte_data(address, reg) l = bus.read_byte_data(address, reg+1) value = (h << 8) + l return value def read_word_2c(reg): val = read_word(reg) if (val >= 0x8000): return -((65535 - val) + 1) else: return val def dist(a,b): return math.sqrt((a*a)+(b*b)) def get_y_rotation(x,y,z): radians = math.atan2(x, dist(y,z)) return -math.degrees(radians) def get_x_rotation(x,y,z): radians = math.atan2(y, dist(x,z)) return math.degrees(radians) bus = smbus.SMBus(1) # bus = smbus.SMBus(0) fuer Revision 1 address = 0x68 # via i2cdetect bus.write_byte_data(address, power_mgmt_1, 0) print "Gyrosk op" print "--------" while(True): gyroskop_xout = read_word_2c(0x43) gyroskop_yout = read_word_2c(0x45) gyroskop_zout = read_word_2c(0x47) print "gyroscope_xout: ", ("%5d" % gyroskop_xout), " skaliert: ", (gyroskop_xout / 131) print "gyroscope_yout: ", ("%5d" % gyroskop_yout), " skaliert: ", (gyroskop_yout / 131) print "gyroscope_zout: ", ("%5d" % gyroskop_zout), " skaliert: ", (gyroskop_zout / 131) # How to send the above sensor data to ThingSpeak ? Please Help.
Ryan Thomas in MATLAB Answers
최근 활동: 2019년 4월 4일

how can i send an instance of speed from matlab mobile to thingspeak repeatedly? thingSpeakWrite(‘chanID’, [speed], ‘WriteKey’, ********)
GAURAV DESHMUKH in MATLAB Answers
최근 활동: 2018년 4월 19일

I'm trying to upload sensor values to thingspeak.I have been able to do the same but the data refreshes every 16 seconds. Is it possible to reduce the delay for uploading the sensor values?

ThingSpeak 정보

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.