This instructable is written as a reference design for those who need to gather sensor data and send it over WiFi at a relatively high-speed. With this solution, rates of up to 1000 times per second are easily achieved. The methods used are also useful for those who are interested in connecting Edison and Microsoft Windows applications using socket-based programming over WiFi. Note:this is a LAN-based solution rather than using the Cloud.
The screen capture of EdisonViewer shows data capture from the Grove potentiometer connected to channel A0. During the capture, the potentiometer was cycled by hand to create the signal shown.
We used the following stock hardware:
- Intel Edison.
- Intel Arduino Breakout Board.
- Grove Starter Kit Plus - Intel IoT Edition, with miscellaneous digital and analog sensors.
- Suitable battery or wall-wart power supply.
- Windows PC running Windows 7 or later version OS.
This instructable includes two executables, one that runs as a client on a Windows PC and the other that runs as a server on the Intel Edison. Code is available for each at the following GitHub repositories:
The executable files are provided for each, so no compilation is required to give this a try.
Edison executable (EdisonServer) includes:
- TCP/IP server with simple command handler
- Time sequencer with preset speeds of 1, 5, 10, 50, 100, 500, and 1000Hz.
- UDP packets are sent at the time sequencer rate and include one sample of analog and digital input data with each packet.
- Digital I/O and analog inputs which are setup to use the channels available on the Grove Base Shield.
Windows application (EdisonViewer) includes:
- TCP/IP client and UDP client sections.
- Real-time graph of incoming digital and analog inputs.
- Ability to enable/disable individual channels on each display.
- UPD packet rate adjust which affects the EdisonServer's rate of sampling and broadcast. 1-1000Hz
- UDP packet counters for visualizing packet count-up, loss, etc.
- Pause/Restart button for pausing and resuming graphs.
- As of 4/20/2015, the mraa library (used for the Edison's digital and analog I/O) has an issue that puts WiFi into a somewhat unstable state. This can be mitigated by not using either the Grove Base Shield channel D7 nor the Arduino Breakout board's on-board LED. (See https://communities.intel.com/thread/63188)
- As of 4/20/2015, the analog inputs work well for 5V setting, but the 3.3V setting causes analog reading issues. (See https://communities.intel.com/message/292907)
Step 1: Load and Run EdisonServer
- Obtain EdisonServer by downloading the attachment from here or from GitHub.
- Copy this to your Edison's home directory (or a directory that you prefer).
- Use putty to SSH into your Edison over WiFi (or other connection if you prefer).
- Use "chmod 755 EdisonServer" to make this file executable. "ls -al" should show permissions similar to: rwx r-x r-x
- Type "./EdisonServer" to run the server. It should indicate "Waiting for accept()...", indicating that it is listening for incoming TCP/IP connections on port 10000
- Go to step 2 for running the EdisonViewer Windows application. The connect request will be initiated from there.
Step 2: Load and Run EdisonViewer
Here's how to run the PC application, EdisonViewer, for interacting with the EdisonServer and displaying real-time digital and analog feedback. (See step 3 for a screenshot of the app.)
- Obtain EdisonViewer by downloading the attachment from here or from GitHub.
- Copy this to your desktop, or a directory of your choice. This file runs stand-alone on Windows 7 or later, and needs no other files to operate.
- You may need to get past Microsoft Windows or your anti-virus program's protections to run this file.
- Once EdisonViewer is running, select Configure... from the top menu. A popup will allow you to select the IP address of your Edison target. Use the same IP address you used for the SSH session in step 1.
- Verify the target IP on the bottom status line and then press Connect to connect to the target.
- If the connection times out, then you may have one of the following issues to resolve:
- Incorrect IP. Try opening a windows console (Run: cmd) and then ping your Edison's IP address to verify you have a connection.
- If ping is responding, then it may be Windows Firewall issue. This can be a little tricky, but is not usually difficult to resolve. You will need to troubleshoot this for your particular version of Windows. Windows Firewall may allow you to add an exception for TCP and UDP connections to ports numbered 10000 and 10001 as used by EdisonViewer.
Step 3: Using Sensors
IMPORTANT: Before connecting digital sensors, please read the following map and connect sensors accordingly.
Grove Base Shield ports configured as:
- Digital Outputs: D2, D3 and D4.
- Digital Inputs: D5, D6 and D8. (D7 is unused pending Intel fix of WiFi issue)
- Analog Inputs: A0, A1, A2 and A3
If you prefer, you may modify the source code for EdisonServer to change the mappings for the Digital I/Os.
If sensors are not connected on some channels, you may see false readings appear on the EdisonViewer graphs as they reflect floating signals on the Edison's inputs.
I hope someone finds this useful. Please let me know if you have specific questions or comments, or see any errors that need correction. Thanks!