goHACK.me Solo Mode
This example demonstrates how to use WiConnect in solo mode to work with goHACK.me. The example is based on an ACKme Mackerel board, but the process to setup solo mode is generic and may be used with any ACKme device capable of working with goHACK.me.
In solo mode, WiConnect provides a virtual connection between GPIOs on your device and goHACK.me. GPIO inputs to your device are automatically monitored and can be viewed on the goHACK.me cloud. You can also use the goHACK.me cloud to change the value of GPIOs to enable cloud control of devices.
There are only a couple of steps required to configure this wireless magic.
- Create/choose a caps file that tells goHACK.me about your device, including the name & type of GPIOs available
- Configure GPIOs and solo mode variables using WiConnect
For convenience, we provide example caps files for all ACKme devices suitable for use with goHACK.me. For each example caps file, we also provide a corresponding solo mode setup script to configure GPIOs and setup solo mode for use with the caps file. You don't have to use our example caps files of course, but they are great examples that demonstrate how to setup your board with goHACK.me. Different caps and setup files can enable different features of the device. Feel free to create alternative caps files and/or setup files. How you use goHACK.me in solo mode is entirely up to you!
Caps & Solo Mode Setup Files
The default example caps file for each ACKme board is called ghm_capabilities.json. For reference, the default caps file & solo mode setup file together with a circuit schematic for an AMW004-E03.3 'Mackerel' board are available for download from the following links.
- Default Example Caps file for Mackerel
- Default Example Solo mode setup script for Mackerel
- Mackerel Circuit Schematic Alternative caps and solo mode setup files demonstrate how to enable the Mackerel DAC:
- PWM and DAC example Caps file for Mackerel
- PWM and DAC example Solo mode setup script for Mackerel
The Caps File Explained
The default example Mackerel caps file is configured with four streams and four controls. It also specifies two message boxes for 2-way messaging with goHACK.me. For more details of caps file format, see goHACKme Device Capabilities. A brief explanation of each of the streams, controls and message boxes follows.
button1 button2 thermistor gpio23
<- This stream is used to monitor when Button 1 is pressed <- This stream is used to monitor when Button 2 is pressed <- This stream is used to monitor the voltage on a thermistor. The voltage responds to temperature changes. <- This stream is used to monitor the digital state of GPIO 23 which is connected to Header 2 Pin 7 on the Mackerel board
led1 led2-duty led2-freq gpio6
<- This control is used to turn LED 1 on or off from goHACK.me <- This control is used to set the duty cycle of a pulse-width modulation (PWM) signal connected to LED 2. The PWM duty cycle is used to change the brightness of the LED. <- This control is used to set the frequency of a pulse-width modulation signal connected to LED 2. The PWM frequency is used to change how often the LED is turned on and off. <- This control is used to set the digital output state of GPIO 6 which is connected to Header 1 Pin 9 on the Mackerel board
<- This message box is used to send messages from the device to goHACK.me <- This message box is used to send messages to the device from goHACK.me
The Solo Mode Setup File Explained
The corresponding default example Mackerel solo mode setup file configures the Mackerel board to autonomously connect the streams & controls to goHACK.me. It also enables solo mode and sets the solo mode sync period.
The file is formatted with each line as a comma separated list. In each line there are three items:
command, arguments, comment
As it runs each successive line of the script WiConnect emits the comment first, then executes the command with its arguments.
The default setup file contains the following commands:
|Free up GPIOs that will be used with goHACK.me|
set gpio.init 0 none set gpio.init 11 none set gpio.init 22 none set gpio.init 21 none set ghm.solo.gpio all none
<- Free up GPIO configured for user button 1 <- Free up GPIO configured for user button 2 <- Free up GPIO configured for user LED 1 <- Free up GPIO configured for user LED 2 <- Free previously configured goHACK.me GPIOs
|Assign GPIOs to Streams|
set ghm.solo.gpio 0 button1 in rising set ghm.solo.gpio 11 button2 in rising set ghm.solo.gpio 7 thermistor adc set ghm.solo.gpio 23 gpio23 inpd
<- Setup Button 1 on GPIO 0 as a rising edge triggered input <- Setup Button 2 on GPIO 11 as a rising edge triggered input <- Setup Thermistor on GPIO 7 as an ADC input <- Setup GPIO 23 = H2 Pin 7 as a digital input
|Assign GPIOs to Controls|
set ghm.solo.sync_period 4 set ghm.solo.enabled 1 set system.print_level 3 save
<- Set goHACK.me auto sync period for solo mode <- Enable solo mode for standalone operation. <- Turn off verbose prints which are not needed in solo mode <- Save configuration
For reference, the variables used to setup solo mode are described here ...
Let's go SOLO!
Now that you have a basic understanding of what is in a caps file and how WiConnect is configured to work in solo mode with goHACK.me, let's get your board connected and working with goHACK.me.
Firstly, you should factory reset your board to ensure that any existing configuration does not get in the way of the demo. Use the commands shown below as a guide to factory reset the board now.
If your board is already activated with goHACK.me, we need to deactivate in order to setup a new caps file. Sign in to goHACK.me and deactivate it now. If this is your first time connecting a board to goHACK.me, don't worry, we'll soon have you setup and ready to go.
Connect to Wi-Fi
Connect to your board to your Wi-Fi network using the network_up command as shown below.
Solo Mode Setup
Download the default example caps & setup file and run the setup script using the ghm_capabilities command as shown below. The ghm_capabilities command actually downloads the caps file & the setup file, sets the caps file for use with goHACK.me, and runs the setup file as a script; it's a very handy command.
If you have your own caps & solo mode setup files and do not want to use example files provided by ACKme, skip the above command and use the following procedure instead ...
- Write your caps file to the file system using the WiConnect file_create command
- Set the caps file for use with goHACK.me using the ghm_capabilities set command
- Configure goHACK.me solo mode variables 1-by-1, or write a setup script and save it to the file system, then run it using the setup cmd command.
If you do not already have an account on the goHACK.me website, go to goHACK.me and create a free account. Activate the board with goHACK.me by using the ghm_activate command.
Open a web browser and connect to goHACK.me, and login. Select the Device tab in the vertical column at the left of the webpage and your device appears.
Monitoring & Control with goHACK.me
With your device connected, press button 1 on your board and within a few seconds, you should see the corresponding button 1 on goHACK.me change to 1. Now try clicking the LED 1 switch on goHACK.me, within a few seconds, the LED on your board will turn on just like magic.