element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Just Encase
  • Challenges & Projects
  • Design Challenges
  • Just Encase
  • More
  • Cancel
Just Encase
Blog [Pool Water Monitoring] #3: Getting started with Arduino IoT Cloud
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Just Encase requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: feiticeir0
  • Date Created: 3 Dec 2021 1:01 PM Date Created
  • Views 3507 views
  • Likes 4 likes
  • Comments 0 comments
  • Waterproof temperature sensor
  • pool_water_monitoring
  • ds18b20
  • arduino nano 33 iot
  • onewire
  • just_encase
  • just encase
Related
Recommended

[Pool Water Monitoring] #3: Getting started with Arduino IoT Cloud

feiticeir0
feiticeir0
3 Dec 2021

Just encase

Hi all.

Hope everyone is well and safe.

While the Kit doesn't arrive, and since part of the monitoring process is sending data to Arduino IoT Cloud, let's create something and get ahead start exploring that world.

I never tried Arduino IoT Cloud it, so this will be an exploratory adventure.

For this project, I'm going to use a DS18B20 waterproof temperature sensor that I have here with an Arduino Nano 33 IOT that I also have laying around here.

Hardware

  • Arduino Nano 33 IoT (one of the ones supported by Arduino IoT Cloud)
  • 4.7K resistor
  • DS18B20 waterproof temperature sensor

Here's the schematics

Electrical Scheme

NOTE: My temperature probe only has 3 wires. Here's the correspondence

Probe Wire Color Signal Arduino Pin
Yellow GND GND
Red VCC 3.3v
Green Signal D4

A photo of the contraption

Arduino Nano 33 IoT with DS18B20

Code

I'm using a piece of code from the Arduino Project HUB that shows how to use this sensors.

How To Use DS18B20 Water Proof Temperature Sensor

I've uploaded the code and it's working fine:

image

I'm sure many of you already know how to work with Arduino Cloud, but if not, Arduino Getting started with the Arduino IoT Cloud is a good introductory guide.

I find this one, Environmental data in the Arduino IoT Cloud to be better - it explains in a different way.

Some problems

I had troubles getting the board to be recognized using MacOS Monterey . Had to install Arduino Create Plugin twice. Only after my second install, it did recognized the board. Although, using the online IDE editor always worked fine.

Adding a device

For this to work, you must have Arduino Create Agent running (Here I'm showing in Windows 11 and MacOS Monterey):

image MacOS Taskbar Arduino Create Agent

First, let's add a device:

image

Give it a name

image

It will begin configuring the device (had to reconnect the device twice)

image

And if everything goes smootly,

image

Now, it should be displayed on devices:

image

Creating a thing

If you press the link directly on the devices TAB, it will lead you straight to a new thing (already had renamed from untitled to Temperature):

image

Now, let's add a variable to hold the temperature values

Here it is: read-write, floating point.

image

Don't forget to configure your network, or it won't be able to send data to the Cloud

image

Sketch

The sketch is very similar to the Arduino IDE - just write your code here.

You will see that a lot of code is already here - what is necessary to send data to the IoT Cloud.

Here's the code to get the temperature from the sensor

/*
  Sketch generated by the Arduino IoT Cloud Thing "Temperature"
  https://create.arduino.cc/cloud/things/c1551af0-54de-4c2d-b127-ea4b27ba6ef0

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float temperature;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include <OneWire.h>
#include <DallasTemperature.h>

#include "thingProperties.h"

#define ONE_WIRE_BUS 4

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors (&oneWire);

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();
  //temperature
  sensors.begin();
}

void loop() {
  ArduinoCloud.update();
  // Your code here
  //getting temperature
  sensors.requestTemperatures();  //send command for readings

  temperature = sensors.getTempCByIndex(0);  //we put the valus into the variable defined on the setup
  Serial.println(temperature);

  //delay(300000); //5 minutes - now for testing
}

/*
  Since Temperature is READ_WRITE variable, onTemperatureChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTemperatureChange()  {
  // Add your code here to act upon Temperature change
}

Almost at the end of the loop function, we have the following line:

temperature = sensors.getTempCByIndex(0);  //we put the valus into the variable defined on the setup

This will put the temperature reading into the variable temperature created in the setup.

In the top of the editor, your Arduino should be recognized:

image

Now, let's upload it to the Arduino.

In the serial monitor, I'm getting this info and it's not connecting to the IoT Cloud

image

But, after arriving home, finally it connected without any problem

Arduino IoT Cloud updating

What I still don't realize is, if it's necessary to add some print for it to show on the serial console and only then it gets uploaded to IoT Cloud (but it does not makes sense) or was just a coincidence.

Dashboard

To visualize the temperature in a nice way, let's create a dashboard with a widget

Just click on "Build a Dashboard", add a Widget and link a variable.

I'm going to add a Gauge to display the temperature.

add a widget

Setup the widget

create a widget

And here it is, updating every time the code updates

Widget on dashboard

And here it is, my first experience with Arduino IoT Cloud.

This wasn't without contacting the Arduino team because of the problems recognizing the Arduino Nano 33 IoT . I've received an email from one of their technicians, saying that the Apple M1 isn't supported by the Arduino Create Agent. But it's working now, but not without some issues - now the Arduino is recognized, in a few seconds it is not.. Now it is.. Now it's not... Slight smile

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube