ESP32 hardware serials on TTGO Lora board
ESP32 hardware serials on TTGO Lora board
@janderkan · 2019-03-09
DS3231 Clock - Another Snippet
This is a simple read and write with only 4 subroutines and no library. If of interest the ZS-042 module contains a DS3231 and on board I2C EEprom so you can get time and storage on one unit. See External EEPROM in the questions section for the latter ( though I must admit I haven''t tried it on this module)
@rodmcm · 2018-12-06
mcp2317 pullup register set
mcp2317 pullup register set
@Hans- Joachim Krahe · 2018-11-19
Reading KY-023 dual-axis XY joystick
SubName: Reading an KY-023 joystick Description: You can use this simple code to read the position of a KY-023 dual-axis joystick.
@Peter Simpson · 2018-09-19
Reading a FC-37 water sensor (2 pin black)
SubName: Reading a water sensor (2 pin black) Description: You can use this simple code to read a 2 pin rain/droplet/water sensor detector. When the sensor is completely dry (no water resistance) the logs will show the value 1023. With this particular sensor the more water there is on it the lower the value will go. I personally found that the value 750 is a good water warning trigger (that is basically 1 drop of water).
@Peter Simpson · 2018-08-20
Reading a water sensor (3 pin red)
SubName: Reading a water sensor (3 pin red) Description: You can use this simple code to read a 3 pin rain/droplet/water sensor detector. When the sensor is completely dry (no resistance) the logs will show 0(zero). With this particular sensor the more water there is on it, the more there is resistance, thus the reading goes higher.
@Peter Simpson · 2018-08-20
Reading data from the TMP36 temperature sensor
SubName: Reading a TMP36 temperature sensor Description: You can use this simple code to read the temperature readings from a TMP36 temperate sensor. A few weeks ago I was speaking to B4X user Sorex when he mentioned to me a temperature sensor called a TMP36, I had never heard of this particular temperature sensor before so I decided to buy 5 of them. Note: Yes there is already code on the forum for this sensor, but I thought that I would share this code as it is a direct conversion from demo Arduino IDE code. This sensor is relatively stable but at times it can drift up and down a little bit. I would personally use the DS18B20 temperature module if you are looking for a seriously stable temperature reading, to me the DS18B20 is a more stable temperature sensor with less temperature drift. If you are looking for a general purpose temperate sensor at a bargain price then you can''t really go wrong with the TMP36, look at the spoiler below to view the readings that I was reading.
@Peter Simpson · 2018-08-20
List module
It may be nice to have a List in B4R, so here is one, quite primitive. The module is a code module so it enables use of one list. If you need more - copy the module and change its name. The array defined in the module has a fixed size which must be set prior to compilation by literals. Sorting will be done only for values of numbers or numerical strings.
@derez · 2018-06-28
Map module
It may be nice to have a map in B4R, so here is one, quite primitive. The module is a code module so it enables use of one map. If you need more - copy the module and change its name. The arrays defined in the module have a fixed size which must be set prior to compilation by literals.
@derez · 2018-06-28
Measure Analog Sensor on Digital Pin
Explanation is in the code. "Resistive Sensors" examples include Photocells (light sensor), Flex sensors, Thermistors (temperature reading).
@AHilton · 2018-04-18
BluePill on B4R
I have a bunch of bluepills and this weekend started to look into using them with B4R. I don''t tend to use these units with arduino projects as I prefer them with MBED. I have discovered a couple of things. 1: Don''t waste your time on a boot block. It barely works. You have to do some electrical mods that are questionable. And the gain is not much. Use SWLINK instead. A module costs under $5 on ebay and is completely integrated into the Arduino IDE and thus works in B4R. No pins to move. 2: Pin mapping doesn''t happen with B4R. I don''t know why as it is a thing in Arduino. Here is a sub that translates.
@mrred128 · 2018-03-11
Various table operation and lookup in PROGMEM
Various table operation and lookup in PROGMEM
@tigrot · 2018-01-22
Define LCD custom characters for HD44780 controllers and compatible.
Here is a code snippet to define custom chars in HD44780 controllers
@tigrot · 2017-11-30
A small sketch to read and write DS1307 RTC
This is a small sample to read and write date and time to DS1307. The single fields for time and date are defined in the B4R part. For this you need to download new libraries called Time and DS1307rtc in Arduino environment. The ones downloaded with Arduino are old. I have put integer constants to initialize the time and date fields. You can chose to get a string via serial interface and extract the values to init the device.
@tigrot · 2017-10-25
STM32 - Bluetooth
Following the tutorial here https://www.b4x.com/android/forum/threads/hc-05-classic-bluetooth.66677/ for connecting bluetooth to android I managed to connect android to stm32 with bluetooth (HC-06 in this case). The connection pins are as explained here https://www.b4x.com/android/forum/threads/stm32-and-softwareserial.84936/#post-538283 . The HC-06 requires 5v as vcc but the rx -tx pins use 3.3v so they connect directly to the stm32 rx-tx pins. The led pin number has to change, I used 32 for the on-board green led.
@derez · 2017-10-14
STM32 - With int/ext RTC and LCD
The attached two applications display real time on LCD 1602 (or similar - just find the address).
@derez · 2017-10-12
MAX30100 interfacing with WEMOS using inline C...
Code to interface MAX30100 (Heart Rate and SPO2 sensor) breakout with WEMOS D1 mini using inline C.
@rbghongade · 2017-10-03
Adafruit Motor Shield V1 for Arduino...
Code , using inline C, for controlling DC motors via Adafruit Motor Shield V1
@rbghongade · 2017-08-30
ByteToRGB algorithm
Most of the data that I am processing for use with WS2812B LEDs is 8 bits and the WS2812B libraries (rNSRainbow and rAdafruitNeoPixels) require RGB format. So I needed a way to convert bytes into RGB. I remembered having done so in an earlier Arduino project and was able to translated the algorithm into Basic. The following Basic code can produce a full range of 256 colors.
@Robert Gately · 2017-08-30
PCA9685 16-channel, 12-bit PWM SERVO board....
Yesterday I received the breakout board for PCA9685 (I2C,16-channel,12-bit PWM) for servo. Here is the B4R code using inline c .Please install the attached Arduino library.
@rbghongade · 2017-08-22
ESP32 with built in OLED display connected to WiFi - Inline C
SubName: An ESP32 with a built in OLED display screen connected to WiFi. Description: With this example source code you can connect your ESP32 microcontroller with a built in OLED display to your local WiFi network (Access Point) and display whatever you want on the screen.
@Peter Simpson · 2017-08-20
ESP32 with built in OLED display progress bar - Inline C
SubName: An ESP32 with a built in OLED display screen updating a progress bar. Description: With this example source code, you can place a progress bar on the screen of an ESP32 microcontroller with a built in OLED display. You can display and update the progress bar using Inline C extremely easily. It''s a pretty simple looking progress bar but it does look good if you need one in your project.
@Peter Simpson · 2017-08-20
Tweak the MB-102 power converter
This is actually a Hardware snippet... In many cases you want to use voltage higher than what the MC needs (5v or 3.3v), for example - when you attach motors, or if you need power directly from the source and not limited by the mb-102 current limitation, like I needed to run Raspberry pi by batteries. I soldered one wire to the connections of the plug socket and from now on I need just to connect this pin to the required user. The ground is common to the ground pins of the mb-102.
@derez · 2017-08-04
Reading/Input and Writing/Output using an PCF8575 16 bit I/O extension shield module
SubName: Manipulating all 16 bits/pins from a PCF8575 16 bit I/O IC using only 2 pins from an Arduino.Description: If you are running out of I/O pins on your Arduino based device then I highly recommend that you take a serious look into using a PCF8575 16 bit I/O extension shield module. With the following code you can easily read from or write to all 16 bits/pins of the PCF8575. Writing to the PCF8575 is a simple task of just writing an array of bytes using WireMaster.WriteTo, for example.
@Peter Simpson · 2017-07-30
ESP8266 Check flash configuration - Memory comparison
SubName: ESP8266 Check flash configuration Description: This code tests if the selected EEPROM settings in the IDE matches the actual device that is being used.
@Peter Simpson · 2017-06-29
ESP32 touch capable sensing pins
SubName: ESP32 touch pins Description: The ESP32 comes with 10 touch capable sensing pins called T0 to T9, these pins are capacitive and extremely easy to read, so easy in fact that I''m not even going to attach a photo to this post. To manipulate a touch pin, you just have to connect a breadboard jumper wire to one of the touch capable pins, in this example I''m using T0 (Touch0) which is on D4 (GPOI4). Once you have connected the wire to the D4 touch pin, you just have to touch the end of the wire with your finger and then read the results. When you touch the pin with your finger the reading will drop. In the example below the reading drops from 89 to 8.
@Peter Simpson · 2017-06-26
Shift Register 74HC595 - Controlling 8+ LED''s with only 3 pins
SubName: Controlling 8 LED''s with only 3 pins from your Arduino through a shift register. Description: Here is some basic code for controlling 8 LED''s through a 74HC595 shift register, you could in fact control a lot more LED''s using multiple shift registers and still only using 3 pins from your Arduino device. You can use shift registers to control anything from LED''s to multiple 8 channel relay modules etc.
@Peter Simpson · 2017-06-17
Interfacing PCF8574 8 bit IO port expander module...
The code snippet interfaces Arduino Uno/ Wemos mini with PCF8574 , 8 bit IO port expander via I2C bus
@rbghongade · 2017-06-06
GFX and Bitmaps
This code uses inline C to store 1-bit bitmaps in the program code (PROGMEM) and draws them with the rAdafruitGFX library. You can use this tool to generate the bitmaps data: https://github.com/ehubin/Adafruit-GFX-Library/blob/master/Img2Code/Image2Code.jar
@Erel · 2017-05-25
5V 8-Channel relay module for Arduino
Here is some basic code for switching an 8 channel relay from ''NO'' (Normally Open) to ''NC'' (Normally Closed). The code is initialising each pin (eight pins in total) in a loop and then runs Loopey. In Loopey each relay is being switched from ''NO'' to ''NC'', this is done one relay at a time with a 100 milliseconds delay until all the relays are closed, then the routine is ran again but in reverse switching the state of each relay one at a time until all the relays are ''NO'' again.
@Peter Simpson · 2017-05-14