How I made an electronic board for telemetry sensors and for controlling peripherals
In the course of creating a waiter robot, a telepresence robot, a self-photobot, some developments have appeared that are not to be shared with the community, that is, to make open-source. One of the working versions was an electronic board, code-named SB version 4.0, using an inexpensive and relatively low-functional Arduino, namely, Nano 3.0. The SB 4.0 board is quite simple and straightforward in order to consolidate its electronics knowledge and soldering skills in its assembly process, it is functional enough to make its own practical projects (for example, turn on a light bulb using signals from a motion sensor and a light sensor or via your Bluetooth command) and the cost of components with delivery when ordering from our Chinese friends with taobao was about $ 55 (including the sensors themselves).
The main purpose of the SB 4.0 board is the hardware interface. Having collected, you can use it to receive and process data from several pre-installed sensors and further decision making and execution of algorithms. For debugging convenience, an interface has been created in OS Windows, in which telemetric readings from sensors and power supply, the state of buttons and servo drives are clearly displayed, and you can send commands to the microcontroller.
In this publication I will describe the characteristics of the board and one of the examples of its use. Again, all this is open-source, under the license CC Attribution Non-Commercial Share Alike.
')
Yes, there are already similar control boards and KITs with sensors (more expensive Arduino boards with shields, Raspberry Pi, amperski iodo), but SB 4.0 differs from them in the presence of a power board and a convenient control program written using the LabView development environment. That is, SB 4.0 consists of two boards: control + power. This will be seen in photos and videos.
Photo of both boards, motion sensor, battery:
Programming
To program the microcontroller, as always, we use C / C ++. We conduct development in the environment of Arduino IDE.
The screenshot shows the interface of the Selfiebot Control Panel, where telemetric readings from sensors and power supply, the state of buttons and servo drives are clearly displayed, and you can send commands to the microcontroller.
Screenshot of the interface:
Performance
SB 4.0 uses one of the most inexpensive Arduino Nano 3.0 platforms with the 8-bit ATmega328 microcontroller. This is sufficient for processing the code and solving problems: controlling robots, the smart home system, etc.
Compatibility
Logical voltage - 5 V, which provides electrical compatibility with the Arduino-periphery.
I / O ports
Microcontroller control pins available. In brackets it indicates the pre-installed elements with which the board already knows how to work.
2 pins that can be configured as digital input / output and PWM output (for two digital servos);
1 pin, digital input / output (for motion sensor);
3 pins, digital input / output (for RGB LED);
1 pin, digital input / output (for end sensor, button);
The I2C bus and the UART port are enabled respectively for the port extender card and the Bluetooth module.
Provides versatility SB 4.0. Agree on power levels, signal levels, type of input / output! Replace the pre-installed sensors with your sensors:
temperatures
noise level
humidity
pressure, etc.
Input pin works on the principle of closed / open. Those. on the pin going to the MK or + 5V, or 0. These values are included in the telemetry data that is sent to the software Selfiebot Control Panel.
The output pin either issues 5V with a load capacity of 1A, or is disabled - 0V. To supply voltage or not to this connector is possible only by an external command or by a command of the firmware algorithm.
It makes no sense to connect analog sensors to digital pins.
Nutrition
Power is supplied through a 2.1 mm power socket, or from Li-Ion batteries with a charge controller. The source is determined automatically.
In the case of power supply through the socket, the recommended input voltage is 12-12.6 V. The DC-DC voltage converters are supplied to the servos - 7 V, to USB1, USB2 and other loads - 5 V. You can use a power adapter or batteries as a power source.
To power the periphery, use pins 5B. When using an external power supply, from pin 5B, you can get up to 1A in total.
The power supply kit includes:
Battery pack 3x18650, 1 pc.
Battery 18650, 3.7 V, from 2200 mAh, 3 pcs.
Charge controller, 1 pc.
Power connector, 1 pc.
DC-DC converters, 4 pcs.
Hall sensor, 1 pc.
Transistors, 3 pcs.
Optocouplers and resistors.
Communication
The Arduino Nano microcontroller is programmed via USB using standard free software from the manufacturer’s MK site. To transfer data between the SB 4.0 and the computer, as always, I chose the inexpensive common Bluetooth module HC-06, with a data transfer rate of 9600 Kb / s. Telemetry data and control commands are sent over this wireless channel.
Dimensions
I got the dimensions of the electronic board of power supply - 100 × 70 × 40 mm. The dimensions of the electronic control board are 90 × 70 × 45 mm. But sure, you can still poshamanit and reduce the size.
The distance between the contacts is 0.1 ″ (2.54 mm).
Microcontroller characteristics
Microcontroller: 8-bit ATmega328.
Clock frequency: 16 MHz.
Flash memory: 32 KB (2 KB used for the bootloader, 30 KB for storing the code of your program).
2k ram.
EEPROM 1 Kb.
Rated operating voltage: 5 V
Characteristics of the electronic board SB 4.0
Rated operating voltage: 12.6 V
Recommended input voltage: 12–12.6 V.
Maximum current from the bus 5 V: 1000 mA
General Purpose I / O Ports: 2
PWM ports: 2
Management board includes the following elements:
Bluetooth module HC-06, 1 pc.
Electronic board of the microcontroller port expander, 1 pc.
Microcontroller Arduino Nano 3.0, 1pc.
Electronic board light level, 1 pc.
Servo Drives TowerPro MG966R, 2 pcs.
Photoresistor, 1 pc.
Motion sensor, 1 pc.
RGB LED, 1 pc.
Button, 1 pc.
Fuse, 1 pc.
Jumper, 1 pc.
Transistor, 1 pc.
Capacitor, 1 pc.
Practical use
Options for practical use:
1. Open / close windows when temperature changes.
2. Turn on / off the fan when the humidity in the room changes.
3. Turn on / off the light in the presence of movement in the dark.
4. Turn on / off the water supply when the soil moisture changes.
5. The inclusion of IR illumination, in the dark.
6. Transfer of any telemetric data to the server via the Internet connection.
Application example for SB 4.0
Purpose: subject to the pressed button, turn on the light when motion is detected.
For this, we will additionally need a relay module, a light bulb (220 ADC or up to 12 VDC).
1. Most often we meet the relay 12VDC and 05VDC. The number indicates which DC voltage value needs to be supplied to the relay input.
2. Consider the work common for Arduino SRD-05VDC relay from Songle.
3. When power is applied to the Vcc pin and the Gnd pin is connected to ground, the green LED lights up.
4. Because we have a single-channel module, then on the board you will see only one signal pin In1. If you set the voltage level to LOW in In1, the red LED on the relay module lights up and the relay triggers with a characteristic click. For Arduino, the digitalWrite (pin, LOW) command is responsible for setting the pin voltage level; To return the relay to its previous state, use the digitalWrite (pin, HIGH) command;
5. Connect the relay module to the SB 4.0 board, which has a motion sensor pre-installed and a user button.
5.1. The signal pin In1 of the relay module is connected to pin 13.
5.3. Download the new firmware and turn on the board power.
If the motion sensor detects a movement, then thanks to our algorithm, the LOW level appears on the external power supply pin, the relay is activated, closing the circuit, and the light comes on.
Thus, if a person passes by a motion sensor, the light turns on.