Skip to content

Latest commit

 

History

History
161 lines (84 loc) · 6.81 KB

octopus-makecode.md

File metadata and controls

161 lines (84 loc) · 6.81 KB

Octopus Sensor Modules with MakeCode

The example uses the ELECFREAKS Octopus Noise Sensor displayed below:

octopus-waterlevel-sensor


Example: Octopus Noise Sensor

Step 1: Connect the Noise to the Breakout Board

The breakout boards provided for this presentation may differ from the one presented below. The breakout boards from DFRobot have a green pin instead of a yellow pin for the GPIO. Nevertheless, this demonstration's functionality is the same, as the order is still SVG.

Connect the water level sensor to pin 1 on the breakout board. The black pin (GND) should be connected to the black wire.

micro:bit with Potentiometer


Step 2: Import the Extensions

Importing the datalogger Extension

Select the Extensions in the Blocks Toolbox.

Extensions Drawer

Search for the datalogger extension and select it.

Searching for the datalogger extension

The datalogger blocks are now available in the Blocks Toolbox.

Importing the Extensions for Octopus Sensor Modules

Note

THIS EXTENSION IS NOT USED TO READ THE ANALOG VALUE OF THE POTENTIOMETER, BUT IS USED TO READ THE OTHER SENSORS.

Datalogger extension

The Octopus blocks are now available in the Blocks Toolbox.


Step 3: Mirror Data to Serial

Drag the mirror data to serial block from Data Logger into the on start block:

block-enable-logging-serial


Step 4: Label the Label the Columns on the MY_DATA.HTM File

Select the set columns block from Data Logger. Drag it under the mirror data to serial block:

block-enable-logging-serial

Name the column.

block-label-columns-named


Step 5: Get a Timed Loop

Get an every <500> ms block from Loops (green):

block-every-ms


Step 6: Get Conditional Blocks

Get two if < > then blocks from Logic (teal):

block-conditionals


Step 7: Get the Conditions

Get two block < > is pressed blocks from Input . Place them in the open space of the if < > then blocks. Make sure that one is A and one is B.

block-every-button


Step 8: Add The Data Logging Block

Get a log data < > block from Data Logger Place it in the if button <A> is pressed then block.

block-if-button-a-log-01

Name the column the same name as in Step 4:

block-if-button-a-log-02

Drag an Octopus block in as the value:

block-if-button-a-log-03

Add a delete log block in the if button <b> is pressed block.

All done

block-if-button-a-log-05

Here is the full code:

block-octopus-all-code

Other ELECFREAKS Octopus Sensors

Here are the sensors that are available to tinker with in this presentation. The code will be the same as above with a sensor-specific code. For example:

Octopus Sensor MakeCode Block
octopus-dht11 DHT11 Temperature and Humidity Sensor octopus-noise-sensor-makecode
octopus-ds18b20 DS18B20 Waterproof Temperature Sensor octopus-noise-sensor-makecode
octopus-noise-sensor Noise Sensor octopus-noise-sensor-makecode
Photocell Photocell Light Sensor octopus-noise-sensor-makecode
PIR Motion Sensor PIR Motion Sensor octopus-noise-sensor-makecode
octopus-noise-sensor Soil Moisture Sensor octopus-noise-sensor-makecode
Ultrasonic Sensor Ultrasonic Distance Sensor octopus-noise-sensor-makecode
octopus-uv-sensor UV Sensor octopus-noise-sensor-makecode
octopus-water-level-sensor Water Level Sensor octopus-noise-sensor-makecode

Data Logging MakeCode Files

Full Code Files

DHT11 Temperature and Humidity Sensor

DS18B20 Waterproof Temperature Sensor

Noise Sensor

Photocell Light Sensor

PIR Motion Sensor

Potentiometer

Soil Moisture Sensor

Ultrasonic Distance Sensor

UV Sensor

Water Level Sensor