In this lesson, we’ll show how to automatically send a Photoresistor Sensor data to your Cayenne Dashboard.
2 Hareware preparation
Parts needed for this lesson as below:
|Ethernet shield W5100||1|
|Photoresistor sensor Module||1|
3 Hareware connection
Connect your Photoresistor with Uno as following diagram
A couple of notes before you get started:
- The Photoresistor uses analog output, so you will need to use the analog pins on the Arduino.
- In this example, we are using a 5v power supply from the Arduino, but we could use the 3.3v as well.
- The provided diagram is just an example of how to connect the hardware. There are many ways to connect devices, so try what works best for you!
4 Add new device
Login Cayenne platform，Click Add new…->Device/Widget
The datasheet will be shown as followed:
Setting the data:
Widgit Name: Give your actuator a name, the default name is Photoresistor
Select Device: Select your Arduino device, the one used in this example is the Arduino Uno
Connectivity：Select your method of connectivity: There are Digital、Analog、Virtual, in this example we use Analog；
Pin: The Arduino may have several pins that can be used as Analog inputs (e.g. Arduino Uno has A0, A1, A2, A3, A4 & A5). we use A0 in this example
Choose Widget: Widgets are used to control a device or are used to show the visualization of data coming from a device. Cayenne has a growing list of custom widgets available for IoT projects. Each widget has its own settings and configuration options.
Choose Icon： Select an Icon to be used for the widget. For example, a temperature sensor could a thermometer Icon.
Then click “Step 1:Sketch File”, the sample sketch will be displayed, copy and paste the sketch into Arduino IDE.
Choose the Board type Arduino Uno and corret Port, remember to use your authentication token. upload the sketch to your Uno board. In the Cayenne dashboard, you can click “Step 2: Add Actuator”
Then the Photoresistor widget will be displayed on your dashboard.
As you can see the luminosity valus is 280 from the datasheet, at the same time you can also read the data from your mobile.