Introduction: Sensor Control Management
Our customer is asking about controlling his medical devices.
He doesn't know about real usage of his devices, and there's a fact that sometimes more services are realized than billed.
As a prototype we decided developing a really fast program that controls several sensors.
This IoT gadget is doing the following:
1) User input (because there is no smart card reader available, button control will be used),
2) Open / close electricity (because there is no electricity actuator available, LED will be put ON / OFF)
3) Register start / stop events including user, date / time (because of time shortage, a LCD display will be used to show events).
We have decided to document this demo configuration and development on Windows platform and tools, because we think there is more information of Arduino on top of other platforms.
Step 1: Assembly
The first thing was assembling the card.
You must follow the really clear instructions from here:
Step 2: Setting It Up ..
The second task was setting up the card, a little tricky if it the magical installer doesn't work, and it happens, sometimes :)
The instructions for downloading and running the installer can be found below:
https://software.intel.com/en-us/get-started-ediso...
In case the installer doesn't work, you must run the manual process: :(
https://software.intel.com/en-us/installing-driver...
The manual process for flashing the firmware is here:
https://software.intel.com/en-us/flashing-firmware...
Just some advice here:
1) Run as administrator,
2) Your USB cable must be connected in the proper jack (serial port, at the opposite corner of the power connector)
Make sure Edison COM port appears after all this configuration process ;)
Step 3: Configuring Board Settings From Terminal..
Instructions to perform this task, are below:
https://software.intel.com/en-us/get-started-ediso...
A terminal emulator like PUTTY must be used.
In order to use PUTTY, you must know the port assigned to Edison and use the parameters recommended in the instructions.
In the instructions, you can find the URL to download PUTTY, but you could use the one of your preference.
In this process, you will configure several things:
1) Manually update firmware (using reboot ota command),
2) Configuring password
In order to configure WiFi, you must follow the process below:
Step 4: Configuring Arduino IDE
In order to connect Arduino IDE to the board, you must connect the board to the proper port, as seen in the image.
For prototyping purposes we chose Arduino IDE.
Some configuration must be made previously to any programming (don't hesitate).
The instructions to configure Arduino IDE follow:
https://software.intel.com/en-us/get-started-ardui...
Basically, board and port are selected.
If your board is not installed, you must install it from Boards Manager (Tools > Board > Boards Manager).
Step 5: And Finally .. Coding !
A program file is named Sketch in Arduino IDE.
Here´s the code of this program:
/*
created 2015 by Paco Rodriguez
This example code is in the public domain. *
//Including headers for Display
#include "rgb_lcd.h"
//Instantiation for Display
rgb_lcd lcd;
//Constants for Color combination
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;
// Constants
// Set pin numbers:
const int buttonPin = 2;
// the number of the pushbutton pin
const int RedledPin = 3; // the number of the Red LED
pin const int GreenledPin = 4; // the number of the Green LED pin
// Variables
int buttonState = 0; // variable for reading the pushbutton status
int buttonPreviousState = 0; // variable for storing the previous state of the device
void setup() {
// initialize LED pins as an output:
pinMode(RedledPin, OUTPUT);
pinMode(GreenledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// Clear and setting initial values for display
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Dispositivo");
lcd.setCursor(0, 1);
// check previous state to change it
if (buttonPreviousState == 0) {
digitalWrite(GreenledPin, HIGH);
digitalWrite(RedledPin, LOW);
lcd.print("conectado!");
buttonPreviousState = 1;
}
else {
digitalWrite(GreenledPin, LOW);
digitalWrite(RedledPin, HIGH);
lcd.print("desconectado!");
buttonPreviousState = 0;
}
}
}
Just one thing here, because there is no library included, by default, in Arduino IDE for the LCD RGB display that comes in the Grove Starter Kit Plus, we added a custom library in order to run this kind of display.
You can include it in the project using two different approaches:
1) Add the separate .h and .cpp files (Sketch > Add file)
2) Add the .h and .cpp files as a ZIP file and include it in Arduino IDE as a Library
The .h and .cpp files can be found here:
https://github.com/Seeed-Studio/Grove_LCD_RGB_Back...
If you wish using the second method, you should download the project from GitHub as a ZIP file and copy it inside the Library folder of the Arduino IDE installation (usually can be found at \Documents\Arduino\libraries in Windows).
Then compile and .. we are done here!
Step 6: Conclusions
Edison is a very powerful tool and sensors and APIs are really great!
You just have to sit, research and enjoy!
All comments and suggestions are welcome!
Next additions will include moving to Node.js, web services and other sensors, keep in touch!