Table of Contents

Function Definition: ts.sendmultipledatatocloud(field_data_1 = 100, field_data_2 = 100, field_data_3 = 100, field_data_4 = 100, field_data_5 = 100, field_data_6 = 100, field_data_7 = 100, field_data_8 = 100)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
field_data_1intThe data for field 1.Integer100
field_data_2intThe data for field 2.Integer100
field_data_3intThe data for field 3.Integer100
field_data_4intThe data for field 4.Integer100
field_data_5intThe data for field 5.Integer100
field_data_6intThe data for field 6.Integer100
field_data_7intThe data for field 7.Integer100
field_data_8intThe data for field 8.Integer100

Description

The function sends multiple data to the ThingSpeak channel. The data is mapped to the 8 fields of the ThingSpeak channel.

Example

Connect your IoT house to the ThingSpeak cloud using PictoBlox Python Environment and send temperature and humidity data every 20 seconds.

In this example, we will send the humidity and temperature sensor data to the cloud on the ThingSpeak servers using PictoBlox Python Environment.

ThingSpeak Channel

Create a channel on ThingSpeak with 2 fields – Temperature and Humidity.

DHT Sensor Connection to Quarky

DHT sensors have 3 pins: GND, VCC, and Signal. You have to connect the following 3 pins to the Quarky Expansion Board:

  1. GND to Ground Pin of Quarky Expansion Board
  2. VCC to 3.3V or VCC Pin of Quarky Expansion Board
  3. Signal to the D3 (Digital Pin) of the Quarky Expansion Board

Script

This code helps to send temperature and humidity data from an IoT house to the ThingSpeak cloud every 20 seconds:

  1. To do this, it first creates objects for the Quarky, ThingSpeak, and IoTHouse classes.
  2. Then it connects to the ThingSpeak cloud with the given channel number, read key, and write key.
  3. After this, it enters a while loop and measures the temperature and humidity from the IoT house, and sends the data to the cloud.
  4. Finally, it waits for 20 seconds before sending the next set of data.
# The following code connects to the ThingSpeak cloud and sends temperature and humidity data from an IoT house every 20 seconds. 
# The code first creates objects for the Quarky, ThingSpeak and IoTHouse classes. 
quarky = Quarky() 
import time 
ts = ThingSpeak() 
house = IoTHouse() 

# Next, the code connects to the ThingSpeak cloud using the given channel number, read key and write key. 
ts.connecttoThingSpeak(1908986, "KCVAWGG8Q4X9OM2L", "VQ8IAZ2MPFECXIO4") 

# Then, the code enters a while loop and measures the temperature and humidity from the IoT house and sends the data to the cloud. 
while True: 
  Temp = house.dhtmeasure(1, "D3") 
  Hum = house.dhtmeasure(2, "D3") 
  ts.sendmultipledatatocloud(2, Temp, Hum, 100, 100, 100, 100, 100, 100) 
  time.sleep(20)  # The code then waits for 20 seconds before sending the next set of data.

 

Output

Read More
All articles loaded
No more articles to load