<p>This article is a high-level overview of using Industrial Grade Vi™ IoT Sim Card to execute industrial/prototype-to-production PoCs rapidly.</p><p>Particle Electron, an out-of-the-box readily available hardware with a cloud bundle environment and Thingspeak open-source data visualization tool, can rapidly transform your ideas into a product using Vi Enterprise-grade IoT sim cards, meticulously crafted connectivity solution specifically for your organizational strategic objectives.</p><p><strong>Hardware components:</strong></p><ol><li>Particle Electron - 1</li><li>DHT22 Temperature Sensor Module -1</li></ol><p><strong>Software apps and online services:</strong></p><ol><li>ThingSpeak API for data visualization.</li></ol><p><strong>The setup:</strong></p><p>Now connect the sensor module DAT pin to D1, Vcc to 3.3v, and Gnd to Gnd of Particle Electron.</p><p>Let’s go to particle.io setup, and in the Electron section, click on <strong>“Setup my Electron.” </strong></p><p><strong><img style="display: block; margin-left: auto; margin-right: auto;" src="https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/Brijesh+1.PNG" /></strong></p><p><strong>https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/Brijesh+.jpg</strong></p><p>To successfully connect to the Device Cloud with a non-Particle SIM, you need to flash your device with special firmware. </p><p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/Brijesh+2.PNG" width="368" height="563" /></p><p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/Brijesh+3.PNG" width="372" height="371" /></p><p>The Electron indicates its status with the color LED. At first, it will blink green while connecting to the cell tower. After a few minutes, it will breathe cyan.</p><p><strong><em>Electron breathing cyan means it’s connected to the internet</em></strong></p><p><strong>The Visualization:</strong></p><p>We will use ThingSpeak to visualize the temperature and humidity.</p><p>Create an account at <strong>thingspeak.com </strong>and create a channel called “Vi IoT Rapid PoC” with 2 Fields called “Temperature” and “Humidity.”</p><p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/BRIJESH+4.PNG" width="391" height="602" /></p><p>Let’s now move to write code for the Electron and to flash that code into the Electron.</p><p>After clicking through the Electron setup, you’ll end up in the online integrated development environment (IDE), where you can program the Electron.</p><p>For this project, we will use an existing library to talk to the temperature sensor and send data to the Thingspeak portal for visualization.</p><p>After naming your app and hitting “Save” (the folder icon), click the bookmark icon on the left to open the library tab.</p><p>Search for the “Adafruit_DHT_Particle” library and click “Include in-app.”</p><p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/Brijesh+5.PNG" /></p><p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://kradminasset.s3.ap-south-1.amazonaws.com/ExpertViews/Brijesh+6.PNG" /></p><p>Do the same for the “ThingSpeak” library, the one written by the ThingSpeak development team.</p><p>Here’s the code that we’ll be using for this project. The Electron samples the temperature and humidity, send the data to ThingSpeak, and sleep for 5 seconds to conserve battery power. When the Electron wakes up 5 seconds later, the code starts back from the beginning.</p><p>// This #include statement was automatically added by the Particle IDE.</p><p>#include <ThingSpeak.h></p><p> </p><p> </p><p>// This #include statement was automatically added by the Particle IDE.</p><p>#include <Adafruit_DHT_Particle.h></p><p> </p><p>// This #include statement was automatically added by the Particle IDE.</p><p>#include <Adafruit_DHT_Particle.h></p><p>#include "Particle.h"</p><p> </p><p>// Set your 3rd-party SIM APN here</p><p>// https://docs.particle.io/reference/device-os/firmware/electron/#setcredentials-</p><p>STARTUP(cellular_credentials_set("********", "", "", NULL));</p><p> </p><p>// This example assumes the sensor to be plugged into CONN2</p><p>#define DHTPIN D1 // what pin we're connected to</p><p> </p><p>// Here we define the type of sensor used</p><p>#define DHTTYPE DHT22 // DHT11 or DHT22 </p><p> </p><p>DHT dht(DHTPIN, DHTTYPE);</p><p> </p><p>/* Thingspeak */</p><p>TCPClient client;</p><p>unsigned long myChannelNumber = ***********;</p><p>const char * myWriteAPIKey = "****************";</p><p> </p><p>void setup() {</p><p> </p><p> // We open up a serial port to monitor the sensor values</p><p> Serial.begin(9600); </p><p> Serial.println("DHT22 test!");</p><p> </p><p> dht.begin();</p><p> ThingSpeak.begin(client);</p><p>}</p><p>void loop() {</p><p> // Wait a few seconds between measurements.</p><p> delay(5000);</p><p> // Reading temperature or humidity takes about 250 milliseconds!</p><p> // Sensor readings may also be up to 2 seconds </p><p> float h = dht.getHumidity();</p><p> // Read temperature as Celsius</p><p> float t = dht.getTempCelcius();</p><p> // Read temperature as Farenheit</p><p> float f = dht.getTempFarenheit();</p><p> </p><p> // Check if any reads failed and exit early (to try again).</p><p> if (isnan(h) || isnan(t) || isnan(f)) {</p><p> Serial.println("Failed to read from Grove DHT sensor!");</p><p> return;</p><p> }</p><p> ThingSpeak.setField(1, (float)t);</p><p> ThingSpeak.setField(2, (float)h);</p><p> </p><p> // Write the fields that you've set all at once.</p><p> ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);</p><p> </p><p> // Give time for the message to reach ThingSpeak</p><p> delay(5000);</p><p> </p><p> // Print the data over serial</p><p> Serial.print("Humid: "); </p><p> Serial.print(h);</p><p> Serial.print("% - ");</p><p> Serial.print("Temp: "); </p><p> Serial.print(t);</p><p> Serial.print("*F ");</p><p> Serial.println(Time.timeStr());</p><p> </p><p>// Publish data to the Particle cloud. </p><p> // Remember that you'll consume data every time you publish to the cloud.</p><p> Particle.publish("temp", String (t));</p><p> Particle.publish("humi", String (h));</p><p>}</p><p>Make sure to put your ThingSpeak channel number, Vi IoT Sim Card APN, and write the API key from before into your copy of the code.</p><p>Let’s hit the lightning bolt icon located at the top-left of the web IDE and flash the program into the Electron! You will get a warning that flashing over the air (OTA) uses a bit of data. At this point, it’s OK to say “Flash OTA anyway.” The Electron will flash purple a few times and restart.</p><p>You should now see that the Electron goes to sleep after 6 seconds and your first data point appear in ThingSpeak.</p><p>After some time, you’ll be able to see a nice graph of the temperature and humidity.</p><p> </p>
KR Expert - Brijesh Kumar Mishra
Core Services
Human insights are irreplaceable in business decision making. Businesses rely on Knowledge Ridge to access valuable insights from custom-vetted experts across diverse specialties and industries globally.
Expert Calls
Our flagship service, phone consultations, enables you to get access to first-hand, grass-root level information from our global expert network to form or validate your hypothesis.