Category: Node-RED

The new BI2 black vibrator development board

The new black BI2 board is ready. I have a few assembled boards ready for shipping. Have a look at www.tindie.com

3 JST 1mm plugs (battery, motor 2, motor 3), LED, reset button, M+/M- is for motor 1

JST 1mm plug for motor 1, alternative RESET button

Features

  • ESP8266 Microcontroller with WLAN
  • MPU9250 (accelerometer, gyroscope)
  • LiPo battery charging
  • 3 motors can be connected (simple motor driver circuits)
  • 1 WS2812B LED – a  colourful LED (16 Mill. colours). They are commonly known as Adafruit Neopixel – a strip or a ring of individual programmable LEDs (when use the WS2812B only two motors can be connected)
  • design based on the great Adafruit Feather Huzaah ESP8266
  • vibration motors and LiPo battery can be easily connected with JST 1mm connectors
  • two reset buttons (the button next to the USB connector can be overmolded)
  • USB connector for battery charging and code uploading
  • programmable with the Arduino IDE or NodeMCU
  • white LED for indicating charging
  • standard LED (yellow) on GPIO00
  • round 40mm diameter

 

There are 3 free GPIO ports. Standard layout are for driving 2 motors (GPIO 12 = M2, GPIO 13 = M3) and 1 LED (GPIO14). Alternatively you can use 3 motors (GPIO12,13,14) but no LED.

Standard: SJ2 not connected, SJ3 connected

Alternative: SJ2 connected, SJ3 not connected

 

Here is the schematic which is adapted from Adafruit.

References:

  • Quick start up guide with Blynk app is here
  •  Assembling a silicone molded vibrator with 3D printed form – tutorial here
  • Complete guide including wireless charging, control with Node-RED and data transmission via MQTT is here

Basic Node for the Internet of Sex Toys – part 3: software

This the third part of the tutorial which has the following parts:

part 1: Basic Node for the Internet of Sex Toys

part 2: Molding the Basic Node

part 3: Software for the Basic Node

For the basic node a simple software realizes all features like Mqtt communication, Web server, basic web user interface, reading data from the accelerometer. Please use the code at github and send request over github. Now the imported parts of the code are explained.

To communicate with the IOT Mqtt is used (read more here). This is a fast protocol for data transmission. Therefore we need a Mqtt server. You can install one on your local computer or use a cloud-based Mqtt server. We use the free CloudMqtt. The following variables must be initiated with the data  of your server. Please get your own account at CloudMqtt or use my server (but don’t spam it, please). Please remember: Transmission is not encrypted, everybody can read it.

const char* mqtt_server = "m12.cloudmqtt.com";
uint16_t mqtt_port = 15376;
const char* mqtt_user = "nvcuumkf";
const char* mqtt_password = "C-X6glwisHOP";

We have now  7 different modes. In each mode the basic node behaves different.

const int offMode = 0;
const int maxMode = 1;
const int sinusMode = 2;
const int motionMode = 3;
const int constantMode = 4;
const int listenMode = 5;
const int listenAndMotionMode = 6;

In off mode the basic node is off, in max mode the vibration is maximum. In sinus mode the vibration speed is altered according to a sinus curve.

Web user interface of the basic node

In motion mode the vibration changes according to the movement of the basic node. When moved fast the speed goes up, when moved slowly or movement stops, the speed goes down. In constant mode any vibration speed can be set to any strength. This feature is only available by Mqtt messages eg. from the IOT node-RED user interface. The listen mode is still experimental. In this mode the speed will be changed by OTHER basic nodes. Finally in the listenAndMotionMode the speed is changed by movements of the basic node and by other nodes. This feature was already available with the body interaction 1 development board as standard mode!

The basic node starts a web server (see image). A web page is generated which build up the user interface. There are buttons for every mode. In addition the speed and the battery power is displayed. This is done in this function:

void generateWebpage() {

The next lengthy procedure is this:

void mqttCallback(char* topic, byte* payload, unsigned int length) {

This is a call back function which is executed whenever a Mqtt message comes in. It parses the Mqtt message which is in the popular JSON format. The commands which are communicated within JSON are explained here. In principle there is a command for every mode, when the command “set mode to off” is send the mode is set to offMode.

In the setup() part of the code you will find a lot of lines like that:

httpServer.on("/MOTOR=MAX", []() {

They corresponds to the generateWebpage() function. When say the max button on the web page is pressed than the affiliated httpServer function is executed. So for every button on the webpage you need a corresponding httpServer function to implement the functionality. In this case (MOTOR=MAX) the mode is set to the constant speed maxMode.

Finally in the loop section of the code the following functions are implemented:

  • reading the accelerometer data
  • change the vibration motor speed according to the mode
  • generate a new JSON message which is send out via Mqtt
  • do the timing

Not mentioned is the OTA (over the air update) function, which is integrated in the code.

Node-RED

For controlling the toy via the internet you can use node-Red. You can find the code at github via this link.

The flow is explained here and here.

 

Smooth 3d printed vibrator form for silicone molding

shinybluemoreorlesscompleteWe started with printing sex toys (see here, here and here), then moved to printing mold forms for sex toys and finally we made sex toys which are partially silicone molded and partially printed. The best results were achieved with printing mold forms and fill them with silicone. But even there we have the problem that the surface isn’t really smooth and that it is hard to clean.

 

xtcTo overcome this problem we use a 3d print smoothing (XTC 3D) to smooth the surface. Application is very easy. It is like applying a transparent varnish. The results are impressive: The silicone gets a smooth shiny surface.

Shiny blue vibrator with vibration motor and air bubble in silicone formBut you can still see printer artefacts. To overcome this issue you could apply a thicker layer of XTC-3D. If you use a better printer than my daVinci 1.0 the “staircase effect” shouldn’t be a  problem at all. Another problem are tiny – sometimes quite large – air bubbles. To remove this air bubbles you need a vacuum chamber. So it is still not perfect, but it works and looks quite good…shinybluecomplete

Internet of (sex) things – part 4: Building a sex toy dashboard with Node-RED

In the fourth part of the tutorial we explain the development of a dashboard for our sex toy.

The series has 4 parts:

part 1: Exploring the internet of (sex) things

part 2: MQTT messages

part 3: Node-RED

part 4: Building a sex toy dashboard with Node-RED

The dashboard is used to visualize certain data eg. the speed of the vibration motor and the movements of the vibrator. In addition it can have some control elements eg. for changing the vibration pattern.

ui-all

The window above is called a tab. You can have multiple tabs. The Motor, Data, Status and Controls – windows are called groups. The Controls – group has buttons to set the motor mode. In addition there is a slider which will set the motor to a constant speed. And there is an on/off button for the LED.

You have to install the Node-RED dashboard. Therefore you need at least version 0.14 of Node-RED. At the time this text was written the standard Node-RED installation is version 0.13 which is not sufficient for the dashboard.

Therefore check your Node-RED version. If it is equal or better than 0.14, skip this step:

  • Download & unzip the latest version from github (eg. https://github.com/node-red/node-red/releases/tag/0.15.2).
  • Now change to newly created directory eg “node-red-0.15.2”
  • On Windows: Start a command shell in adminstration mode
  • Execute “npm install” to install Node-RED.

If your Node-RED version is 0.14 or better install the dashboard:

Some  remarks:

Let’s start and have a look at the new Node-RED interface: On the left side you will find the dashboard or user interface nodes. And on the right side there is new dashboard – tab. It contains all dashboard nodes which are used in the flow ordered hierarchical.

node-red-ui

But where is the dashboard? Just open your browser and go to one of the URLs:

http://localhost:1880/ui/#/0 or
http://127.0.0.1:1880/ui/#/0

How can I get all the flows? You can download all flows here: bi-ui-node-red. Unzip the file and you will get a text file. Open the text file in an editor. Select the text and copy it to the clipboard.

Now we will explain two flows in detail.

Now go the Node-RED window, open the menu (it is on the left top side), select Import -> Clipboard.import1

A new window will open where you can insert the text (CTRL+V). Then press the Import-button.

import2

nodemcu prototype breadboardThe Arduino sketch was updated for the dashboard. Please download the Arduino sketch from here: iost-part4-v12. Unzip the file. Compile and upload to your hardware (see part 1 of the tutorial).

 

In the first flow we will receive some vibration motor sex toy data which are sent by the MQTT protocol. We will display the data using a gauge and a graph element.

Let’ start with the MQTT input node. There is nothing new. Just connect to the MQTT server and subscribe the topic “BIoutTopic2” – which the sex toy uses to send out data.mqtt-in

Now add the function node “JSON” which will parse the incoming message and places the result in “payload”.

But we want to know the motor speed only. Therefore we need a function node which passes the vibration motor speed as payload and deletes all other data. Please use the following JavaScript code:

get-motor-speed-function-node

To display the speed we need to more nodes. The gauge node gauge-node displays the actual speed. Connect the gauge node with the function node. You can add the range – the minimum and maximum value (0 and 1023).motor-gauge

 

Now add a chart node chart-nodeand connect it with the function node, too.

 

Next we want the chart node and the gauge node to be together as shown in the next image.

motor

We have to make a group and put both nodes into the group. Have a look on the dashboard at the right side. Make a new group and move the gauge and chart node below the group called “Motor”.

dashboard-top

slider-nodeNow we explain the second flow. It is used to send commands to the sex toy. We will use a slider to control the speed. But there is one problem: the slider should display the actual speed of the vibration motor. Therefore we manipulate the slider. To display the actual motor speed we have to move the slider appropriate to the actual speed. The slider will be part of the control group:

controls

Now get the slider node and edit the node as follows:

slider-motor-speed

Then connect the node with the “get motor speed” function which was introduced in the first flow.

construct-json-motor-speed-function-nodeFinally comes the trick part. Get a new function node and connect it with the slider. This node will construct the JSON message which will be sent to the sex toy using MQTT. The JavaScript code of the function node is as follows:

function-node-for-constructing-json-speed-command

msg.payload={messageType:"execute", actuator:"motor1",
             actuatorMode:"constant", actuatorValue:msg.payload}
msg.topic = "BIinTopic";
return msg;

Now connect the function node with a new MQTT output node. Leave the topic empty as it will be passed from the input nodes:

mqtt-out-message-to-bi

Using Node-RED with the Node-RED dashboard we are able to make a user interface for our sex toy(s). We could easily display the motion of the sex toy as well as the vibration motor speed. You could argue that we had a (very simple) user interface already in part 1 of the tutorial, without having to use MQTT, Node-RED and the Node-RED dashboard. That’s true. But imagine you have several sex toys and want to control them. You could easily add a tab in Node-RED for each sex toy. Or you could build more sophisticated flows incorporating several sex toy. Why not interconnecting the vibrating necklace with a penis ring and one of the plugs or dildos?

There are a lot of flows and nodes already available at http://flows.nodered.org/. (Of course not in the sex toy domain)

Why not play music for a given sex toy vibrator mode? Or control the sex toy using another IOT device…