#help-with-arduino

1 messages · Page 37 of 1

woven mica
#

Looks like the library uses generic types, did you look at the library documentation about the usage of parameters?

mild elk
#

no, I did not

woven mica
#

Where is the library, I will look at it

mild elk
woven mica
#

What function are you calling?

mild elk
#

I used code generated by assistant website

woven mica
#

Paste here the parsing part of your code

mild elk
#

Ok, give me a sec

#
client.readString().toCharArray(json, 10000);
  const size_t capacity = 3*JSON_ARRAY_SIZE(12) + 36*JSON_OBJECT_SIZE(2) + 109*JSON_OBJECT_SIZE(3) + 36*JSON_OBJECT_SIZE(7) + 12920;
DynamicJsonDocument doc(capacity);

deserializeJson(doc, json[10000]);
JsonArray league = doc["league"];

JsonObject league_0 = league[0];

JsonObject league_0_stage_b = league_0["stage_b"];
char* league_0_stage_b_name = league_0_stage_b["name"]; // "Port Mackerel"

char* league_0_game_mode_name = league_0["game_mode"]["name"]; // "League Battle"

JsonObject league_0_rule = league_0["rule"];
char* league_0_rule_name = league_0_rule["name"]; // "Splat Zones"

long league_0_start_time = league_0["start_time"]; // 1561996800
long league_0_end_time = league_0["end_time"]; // 1562004000

JsonObject league_0_stage_a = league_0["stage_a"];
char* league_0_stage_a_name = league_0_stage_a["name"]; // "Piranha Pit"

JsonArray gachi = doc["gachi"];

JsonObject gachi_0 = gachi[0];

JsonObject gachi_0_rule = gachi_0["rule"];
char* gachi_0_rule_name = gachi_0_rule["name"]; // "Rainmaker"

char* gachi_0_game_mode_name = gachi_0["game_mode"]["name"]; // "Ranked Battle"

JsonObject gachi_0_stage_b = gachi_0["stage_b"];
char* gachi_0_stage_b_name = gachi_0_stage_b["name"]; // "Manta Maria"

long gachi_0_start_time = gachi_0["start_time"]; // 1561996800

JsonObject gachi_0_stage_a = gachi_0["stage_a"];
char* gachi_0_stage_a_id = gachi_0_stage_a["id"]; // "12"
char* gachi_0_stage_a_name = gachi_0_stage_a["name"]; // "Shellendorf Institute"

long gachi_0_end_time = gachi_0["end_time"]; // 1562004000
#

JsonObject regular_0 = regular[0];
long regular_0_end_time = regular_0["end_time"]; // 1562004000

JsonObject regular_0_stage_a = regular_0["stage_a"];
char* regular_0_stage_a_name = regular_0_stage_a["name"]; // "Skipper Pavilion"

JsonObject regular_0_stage_b = regular_0["stage_b"];
char* regular_0_stage_b_name = regular_0_stage_b["name"]; // "Starfish Mainstage"

char* regular_0_game_mode_name = regular_0["game_mode"]["name"]; // "Regular Battle"

JsonObject regular_0_rule = regular_0["rule"];
char* regular_0_rule_name = regular_0_rule["name"]; // "Turf War"

long regular_0_start_time = regular_0["start_time"]; // 1561996800
Serial.println(regular_0_rule_name);
Serial.println(regular_0_stage_a_name);
Serial.println(regular_0_stage_b_name);
Serial.println(gachi_0_rule_name);
Serial.println(gachi_0_stage_a_name);
Serial.println(gachi_0_stage_b_name);
Serial.println(league_0_rule_name);
Serial.println(league_0_stage_a_name);
Serial.println(league_0_stage_b_name);
woven mica
#

deserializeJson(doc, json[10000]); should be deserializeJson(doc, json);

mild elk
#

Ok, I'll correct that

#

Still the same error

woven mica
#

At what line is the error?

undone python
#

How to hack satlites

mild elk
#

At none, it just says "Error compiling for board Generic ESP8266 Module"

#

In file included from /home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Operators/VariantOperators.hpp:7:0,
                 from /home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp:12,
                 from /home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp:8,
                 from /home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp:9,
                 from /home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson.hpp:17,
                 from /home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson.h:9,
                 from /home/pi/Documents/Arduino/test_json_esp8266_parse_in_place/test_json_esp8266_parse_in_place.ino:3:
/home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Operators/VariantCasts.hpp: In instantiation of 'ArduinoJson6111_00000::VariantCasts<TImpl>::operator T() const [with T = char*; TImpl = ArduinoJson6111_00000::MemberProxy<const ArduinoJson6111_00000::ObjectRef&, const char*>]':
/home/pi/Documents/Arduino/test_json_esp8266_parse_in_place/test_json_esp8266_parse_in_place.ino:63:54:   required from here
/home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Operators/VariantCasts.hpp:16:35: error: invalid conversion from 'ArduinoJson6111_00000::VariantAs<char*>::type {aka const char*}' to 'char*' [-fpermissive]
     return impl()->template as<T>();
                                   ^
#
/home/pi/Documents/Arduino/test_json_esp8266_parse_in_place/test_json_esp8266_parse_in_place.ino:65:61:   required from here
/home/pi/Documents/Arduino/libraries/ArduinoJson/src/ArduinoJson/Operators/VariantCasts.hpp:16:35: error: invalid conversion from 'ArduinoJson6111_00000::VariantAs<char*>::type {aka const char*}' to 'char*' [-fpermissive]
exit status 1
Error compiling for board Generic ESP8266 Module.```
woven mica
#

What code is on line 63?

#

in your program

mild elk
#

char* league_0_stage_b_name = league_0_stage_b["name"]; // "Port Mackerel"

woven mica
#

try to put const char* league_0_stage_b_name = league_0_stage_b["name"]; // "Port Mackerel"

#

before every char* you read add const

mild elk
#

🤔 ok, but this is meant to be updated and constants shouldn't be changed

#

I get wdt reset @woven mica

#

It receieves the data, but nothing is printed to serial console

#

I tried with just char instead of const char*but it does the same

desert adder
#

Hi there. I am using the feather M4 Express with the prop maker board and programming it with the Arduino IDE. How can I make the flash memory on the Feather accessible by my computers OS so I can place WAV files on it for audio playback?

north stream
#

I'm not sure, but I think if you flash the UF2 bootloader code onto it, you can treat it as a removeable drive, then switch back to Arduino to load the code to use the files. I haven't tried that, however.

desert adder
#

I keep trying that and it is like it erases whatever is on the flash drive.

north stream
#

That's annoying.

desert adder
#

Yea@ I can get it to say the audio file is present not, and the speaker powers up but no WAV file. I still think it has to do with the reboot and wiping the flash partition.

north stream
#

I wonder if it's possible to modify the loader to skip the erase step.

desert adder
#

I was wondering that but I am kinda new to the whole UF2 thing.

#

Or load my files into an updated UF2 file.

north stream
#

At that point, it's probably easier to just put them onto flash with an Arduino program.

foggy quiver
#

How do I add SERCOMs on the Feather M4 in Arduino?

long sphinx
#

anyone using an esp32 dev board and able to determine battery % remaining?

desert adder
#

@north stream I got it to read the files. It just now does not play them in analog mode. It thinks it is, but it is not.

north stream
#

Bleah, one step at a time, eh?

burnt island
#

what are you trying to use the SERCOMs for?

pine bramble
#

IDK what i want to make

pine bramble
#

anyone knows any virtual usb keyboard library or how to code it yourself which works on attiny45/85? I need it to be arduino code..

north stream
#

The USB support for the ATtiny series just barely works, and less so for newer computers (unless you're thinking of adding something like a MAX3421 chip). I'm guessing emulating a working keyboard would be problematic.

woven mica
#

@pine bramble you can try looking here: https://www.obdev.at/products/vusb/prjhid.html or maybe this https://www.obdev.at/products/vusb/easylogger.html could do.

#

but it is not Arduino code

pine bramble
#

Is it hard to code in non-arduino IDE?

#

I never touched anything else than arduino ide

#

I tested it out, it works on attiny85

#

Anyone knows how to code it without arduino?

woven mica
#

Do you really need to do it with ATtiny? You could do it with ATMega32u4 easily

#

It has native USB - Arduino Micro has ATMega32u4

desert adder
#

Hey There. with the help of Carter from Adafruit Support I was able to read/write to the Flash Memory on the M4 Express. We used the TinyUSB stack and exposed it as a drive. The next issue I am running into is that I can't get analog audio out working on pin 0 . The M4 Express (SAMD51) has a fork of the PJRC Library, and now it says it is playing, but no audio out. Any suggestions? I posted about it in the forum as well.

north stream
leaden widget
#

Question, on using the Arduino setup for the pygamer board, what are the correct settings to upload? Need to know what options just past the Install SAMD step to use for upload test. I get a fail using trial and error and there are no specific directions that I can locate here. https://learn.adafruit.com/adafruit-pygamer/using-with-arduino-ide . And what programmer for this device is correct? Getting this error with the current board selection : Error compiling for board Adafruit PyGamer Advance M4 (SAMD51)..

Adafruit Learning System

Fits in your pocket, is fully Open Source, and can run CircuitPython, MakeCode Arcade or Arduino games you write yourself!

crisp talon
#

this may sound like a weird question but has anyone ever hooked up two different arduinos to the same vl53l0x? I want to try it and I am curious if anyone has done it before

sonic rock
#

don't know.

#

What exactly are you trying to do?

north stream
#

Since it's I2C, you won't burn anything if you get a bus conflict.

viral crystal
#

Anyone get an hx711 + load cell working with an ESP32? I got it working with a regular Arduino UNO just fine but using the same exact setup on the ESP32 results in nothing but 0 values being read

#

I tried many different libraries and even tried powering it via 5V and using a level shifter (to protect the ESP32 from 5V in on the pins)

tardy cipher
#

Hi, has anyone here dealt with particle/arduino code? i'm having some very frustrating issues and especially with particle their isn't much places to go for help. If anyone could help (language is of course c++)

viral crystal
#

OK never mind: I can't even get friggin blink to run on this ESP32... I think it's hosed. I mean, it flashes fine and blinks the built-in LED just fine but it doesn't seem to be working with any of the normal GPIO pins

#

OMG YES! IT WORKS WITH A REGULAR ESP32! Woohoo! All my problems have been with the generic Heltec esp32 with the built-in OLED. Not sure why none of the GPIOs are working... Maybe I fried it somewhere along the way (I doubt it)

crisp talon
#

@north stream so it's safe to try out with no risk to the boards?

foggy quiver
#

How do I add SERCOMs on the Feather M4 in Arduino?

north stream
#

Yeah, I2C just has pull-up resistors, and all the masters and targets just pull down the lines, so if they conflict, they'll both just be pulling down, so no risk of overcurrent or damage due to push-pull conflict.

#

I thought Arduino offered Serial1, Serial2, etc. for the M4

foggy quiver
#

@north stream It doesn't seem to. Using Serial2 doesn't compile.

#

I need a UART

north stream
#

Hmm, thought the M4 had more than one UART.

foggy quiver
#

It does, but the Feather only exposes 1. But, with SERCOMs, I can add more, if I could figure out how to get it to work

north stream
#

Might be as easy as altering pins.h/variant.h or might require programming MUX registers and all that.

random oyster
#

have you looked at this? https://www.arduino.cc/en/Tutorial/SamdSercom
do you need something different?

as madbodger said you can just write to the registers, you should also be able to mix frameworks/libraries, e.g. Arduino and ASF 3, but don't quote me on that (and that'd probably be a pain to work with, I've never tried).

foggy quiver
#

I'm not sure where the last 2 SERCOMs are. I've found 1,2,5, but not 0,3,4

north stream
#

May only be available on a higher pin count package, or they conflict with another function in use.

burnt island
#

datasheet says the SAMD51J19 has 6 SERCOMs.... Now where do they pop out....

burnt island
#

well, this compiles and there's a possibility that it might work but I suspect there are small things wrong, like having the pads reversed or PIO_SERCOM vs PIO_SERCOM_ALT:

// to get the pinPeripheral function
#include "wiring_private.h"

// Sercom 1,2,5 are used by default

// A4 A1 = IOSET3
Uart Serial2( &sercom0, A4, A1, SERCOM_RX_PAD_1, UART_TX_PAD_0 ) ;

// use the SPI pins
Uart Serial3( &sercom1, 5, SCK, SERCOM_RX_PAD_1, UART_TX_PAD_0 ) ;

// use the i2c pins
Uart Serial4( &sercom2, SDA, SCL, SERCOM_RX_PAD_1, UART_TX_PAD_0 ) ;

Uart Serial5( &sercom3, 10, 11, SERCOM_RX_PAD_1, UART_TX_PAD_0 ) ;

Uart Serial6( &sercom4, A2, A3, SERCOM_RX_PAD_1, UART_TX_PAD_0 ) ;

// sercom5 is already Serial1

void setup() {
  // put your setup code here, to run once:
  Serial2.begin(115200);
  // attach the sercom units to the pins
  pinPeripheral(A4, PIO_SERCOM);
  pinPeripheral(A1, PIO_SERCOM);
  
  Serial3.begin(115200);
  // attach the sercom units to the pins
  pinPeripheral(5, PIO_SERCOM);
  pinPeripheral(SCK, PIO_SERCOM);
  
  Serial4.begin(115200);
  // attach the sercom units to the pins
  pinPeripheral(SDA, PIO_SERCOM);
  pinPeripheral(SCL, PIO_SERCOM);

  Serial5.begin(115200);
  // attach the sercom units to the pins
  pinPeripheral(10, PIO_SERCOM);
  pinPeripheral(11, PIO_SERCOM);

  Serial6.begin(115200);
  // attach the sercom units to the pins
  pinPeripheral(A2, PIO_SERCOM);
  pinPeripheral(A3, PIO_SERCOM);


}

void loop() {
  // put your main code here, to run repeatedly:

}
humble anchor
#

Are they used on the USB port?

proven token
#

hey! so I need some help with setting up high-resolution pwm on the arduino mega

#

this is the code i'm using to set up the registers

#

the one on top is example code designed for the arduino uno that works great

#

the one on bottom is me trying to set up code for timer3

#

figured it out omfg

#

ive been trying to figure this out for days

#

i just set up the pins wrong im not sure how

#

but if I use pinMode(pin, OUTPUT) it works great

#

ok it is 16 bit pwm time baby

#

jk 14 bit

#

i have to set it up through the registers all at once

#

the pins

#

that is what i was doing wrong

knotty rover
#

I'm having trouble with a feather m0 bluefruit. I'm trying to use it as a bluetooth device with a windows 10 machine. Is that setup supported, none of the examples seem to work. the controller doesn't show up as a gamepad, uart doesn't show up as a serial port. will it only work with the app on a mobile device?

humble anchor
#

I think it should work with a PC, it probably uses something generic

#

Does connecting with your phone work?

#

Also, make sure your computer supports bluetooth Low-energy

#

Forgot to tag you @knotty rover

burnt island
#

I don't think there is a driver that makes BLE "Nordic serial port" devices show up as serial ports in Windows, or any other OS.

north kelp
#

@crisp talon I don't think it would be easy for two Arduinos talk to the same I2C sensor. What I would try is having one talk to the VL53L0X, and have the two Arduinos talk over I2C to each other:

https://www.arduino.cc/en/Tutorial/MasterWriter

foggy quiver
#

@burnt island That doesn't seem to actually work

crisp talon
#

@north kelp I know that i2c or uart communication would be easier but I was just curious if two arduinos could be on the same vl53l0x as another way to do it.

mild elk
#

Is it possible to use 128x64 graphical LCD like RG12864A-TIG-V with Adafruit-GFX library?

north stream
#

Ought to be, if your CPU has enough memory.

obtuse mist
#

Hey folks, has anyone gotten the tinyusb mass storage controller to work on something small like the Trinket M0? Is there an example that reads a config file that's writeable from the host?

solid jetty
#

I'm having difficulties with my map function

#

can anyone possibly help

mild elk
#

@north stream but this display has no serial interface, is there a library that will work with Adafruit-GFX and parallel display?

humble anchor
#

@crisp talon hmm, maybe it could be done. But when one is talking to it, the other has disconnect its i2c pins (or set to high impedance) otherwise it won't work

north stream
#

Heh, that's a different question entirely! The GFX library itself is (by design) display agnostic and will work with pretty much anything, but you'll need a driver for the display and possibly a shim to adapt it to the GFX calling conventions. Since I don't know what display you have, I have no idea what libraries (if any) are available for it. My guess is there is at least one Arduino library in existence and that it's not written for GFX, so your options are probably a) modify the library to work with GFX, or b) write a shim that sits between GFX and the library.

#

Whether it's a serial interface or not is immaterial, the display communications are handled by the display library: GFX just tells the library what to do (clear display, draw a pixel at this location, etc.)

mild elk
#

RG12864A-TIG-V

woven mica
#

The LCD is said to use NT7108 driver, which is compatible with the KS0108B LCD driver (which is more common), so you need a library for KS0108B.

#

@mild elk

#

Seems like there is no Adafruit GFX library interface for this LCD driver.

humble anchor
#

What do functions do you want to use? @woven mica

woven mica
#

I was just helping Kaktus with finding a library for the display.

humble anchor
#

Aaah

#

For text I usually use u8g2 instead of something like adafruit libraries

woven mica
#

Yes, u8g library supports this LCD

mild elk
#

Thanks
I'll see what this library can do
Maybe it will do without GFX library

crisp talon
#

@humble anchor so this is what I was thinking:

only one of the two arduinos connects to the VIN, GND, and SHDN pins of the vl53l0x. In the arduino set up code that arduino then sets the adress of the i2c adress that both arduinos then use (predetermined beforehand when the code was written).

then could they(each arduino) not each call it whenever they need to (of course as long as they don't both call the vl53l0x around the same time)? Or would we have to set the other arduino's pins to high impedance?

humble anchor
#

I would just look for arduino i2c multi master design

crisp talon
#

@humble anchor Nice! thanks!

elfin oar
#

What is the best way to replace an arduino standard library? I want to use the Adafruit fork of the SdFat library. I put it in my arduino/libraries folder, but I don't know how to tell it to grab that one instead of the standard SdFat library. The library manager does not allow uninstall.

crisp talon
#

@elfin oar Are you using a windows computer? I may have a solution if yes.

elfin oar
#

Yes, windows

#

I'm trying to build the latest tinyusb msc_external_flash demo

crisp talon
#

@elfin oar okay if you go into file explorer:

Local disk-Users-(your account in my case it would be artistofcannae)-documents-arduino

#

you should be able to find a libraries folder

#

do you see it?

elfin oar
#

Yes, that is where I put the new library.

crisp talon
#

then I'm pretty sure you can delete the old library that you don't want right now and reinstall it later if needed

#

did that work?

elfin oar
#

I don't see the other library anywhere. I think there is only the one copy, but the library manager doesn't know the difference.

#

I pulled the latest Adafruit_SPIFlash, Adafruit_TinyUSB, and SdFat from github, and the msc_external_flash example gives me this error: 'Adafruit_FlashTransport_SPI' does not name a type

crisp talon
#

@elfin oar wait so did you end up deleting the library?

#

(the only one there was and re downloading the right one?)

neon pier
#

is there a place to talk about Adabox 012?

elfin oar
#

The other library was never there. The library manager said the default one was installed, but it was my copy from Adafruit github repo.

elfin oar
#

I can't build the examples that use Adafruit_SPIFlash, but the SD card examples still work.

crisp talon
#

@elfin oar sorry I don't think I can help much more than that

pine bramble
random oyster
#

what have you tried so far? where are you stuck?

pine bramble
#

It's just outputting me 0

#

I'll upload the code

#

I'm not sure what's wrong with readcapacitive function, tried many stuff, but still not working

#

I have a terrible idea!

#

I can try including <Arduino.h>

pine bramble
#

It's too hard

#

:[

random oyster
#

are you sure you've got the pins setup correctly? It looks like you're using different pins in the two bits of code, are you using different boards/setups?

pine bramble
#

I tried turning on LED on the pin I had the capacitive key

#

and the LED blinked like I programmed it to do

#

so I think it's correct pin

#

I'm using exact same stuff

#

not even changing wires

#

I compile with this command:

avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny45 -o blink.o blink.c && avr-objcopy -j .text -j .data -O ihex blink.o blink.hex && avrdude -c avrisp -b 19200 -p attiny45 -P /dev/ttyUSB0 -U flash:w:blink.hex

I think that works, programs upload correctly

#

Wait a second, I haven't tried changing PORTB though

#

I have changed slightly avr code but it should still work

#

Wait!

#

I know what to do!

#

I'll just put AVR code inside arduino IDE and I may possibly find faulty part inside function

pine bramble
#

FIXED!

random oyster
#

nice 😄
how'd you fix it?

winter furnace
#

hey y'all, I am a bit new to the arduino platform and I'm running into a problem

#

I'm using an arduino nano with the 1.8.9 sdk

#

Looking at the language ref, it seems like I should be able to left shift up to 32 places

#

If I run this, I get the output I expect, a 1 shifted 24 places to the left

#

Serial.print(16777216, BIN);

#

but if I run this, I just get 0

#

Serial.print(1 << 24, BIN);

#

It works as I would expect up to 16

#

but after that, it seems to overflow back to 0

#

is there anything else I need to do to force it to treat 1 << 24 as an unsigned long?

woven mica
#

Try Serial.print((long)(1 << 24), BIN);, as the default type, int, is 16 bits on arduino

winter furnace
#

Thank you! Works perfectly.

#

I'm more of an assembly guy so the arduino sdk is a bit new to me 🤣

winter furnace
#

FINALLY!

#

I have been at this on and off for months

#

I'm trying to get the data off of these chinese DRO scales, but without an oscilloscope I had a very hard time reversing the protocol

#

it looks like the relative position has all its bits inverted compared to the absolute position it reports, for no particular reason

#

sooo happy to finally get some usable data off of these things; now I can mount them on the mill and get on with my life 😃

winter furnace
#

huh, I just realized I accidentally cut out my forward decs a while ago but my code still works 🤔

candid wren
#

I am currently using a dualshock 4 controller with an arduino mega adk for a project but I am trying to move to the feather series. Can I use the bluefruit feather nRF52 with a dualshock 4 controller? If not, are there other microcontrollers that might be compatible?

burnt island
#

I think the nrf52 is probably your best bet for "controller" side bluetooth without going all of the way up to a Pi. I'm not sure the libraries are available to make it easy

burnt island
#

hmm, it doesn't look like the adafruit nrf52 library doesn't handle bluetooth classic which the DS4 uses, only BLE

candid wren
#

Ahh ty

burnt island
#

if you use the nordic SDK directly you can probably do it. It's probably not too terrible

humble anchor
#

A device sends a 5V trigger signal to my arduino Uno on pin 2. Do I need a small resistor between 5V signal and the pin?

#

O wait nvm, that is only when using something that is like a button

sick socket
#

Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
getting this errors while printing Adafruit GET request on adruino serial monitor

#

Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Methods: POST, PUT, DELETE, GET, OPTIONS, PATCH
Access-Control
llow-Headers: DNT, Origin, X-Requested-With, X-AIO-Key, Content-Type, Accept, Authorization
getting this errors while printing Adafruit GET request on adruino serial monitor, and not getting the html code

pulsar charm
#

can analogRead values differ from measured voltage?

humble anchor
#

Yes but they shouldn't be @pulsar charm

peak moss
#

Hey all. Anyone know where I can find good info on changing the PWM resolution of the Mega2560. I've already got it changed to 10-bit but need to change it to 12-bit and simply can't find the way via google!

#

I just need to change a PWM pin to 12-bit resolution for an analogWrite()

stark bridge
#

The PWM resolution for fast PWM can be fixed to 8-bit, 9-bit, or 10-bit, or defined by either ICRn or OCRnA. Theminimum resolution allowed is 2-bit (ICRn or OCRnA set to 0x0003), and the maximum resolution is 16-bit (ICRn orOCRnA set to MAX).

#

So it looks like it depends on how the library author chose to do it. Did they lock it at 10 bits or do they allow it to go up to 16 bits?

humble anchor
#

@peak moss Try 16-bit and just go in steps of 16

peak moss
#

I think setting it to 16 bit may be a poor idea as from what I've read it caps the PWM freq at like... ~200Hz

humble anchor
#

That's why you go in steps of 16!

peak moss
#

Ahh okay

#

Could I ask for a little bit more info on how to go about this? Apologies but messing with registers is something I have never done.

humble anchor
#

could be that it is still 200hz

peak moss
#

I'll know if it is. It's controlling an interometer arm with a piezo element. 200Hz is hella noisy 😄

humble anchor
#

@peak moss And it works only with 5V?

peak moss
#

It takes a lot more but I'm running it through an amplifier

#

So from my 5v I get a range of about 0-24V

humble anchor
#

I usually just take a different board in this case

peak moss
#

We are considering picking up a Due or something that comes with analogWriteResolution() but figured trying it this way first should be aworth a shot

humble anchor
#

Hmm, I would rather go with a teensy 3.2 or something

peak moss
#

I'll need to look into that. I am using the Arduino to set up a PID which reads an intensity and varies the piezo arm to correct and lock my laser.

#

Started at 8-bit res, no where near good enough. Kicked it up to 10-bit and its decent. 12-bit would make it perfect I feel.

#

Thanks fort the help btw

humble anchor
#

But something that support analogWriteResolution() might be easier

peak moss
#

Yeah I certainly think so

humble anchor
#

Teensy 3.2 would be pretty good in this case

#

If the mega thing does not work

#

The teensy also has a dav what might be better in this case

peak moss
#

I'll be sure to have a look at the Teensy. Thank you for the recommendations Bonnom. You have been a great help.

humble anchor
#

No problem!

fickle seal
#

I like to program a midi device were in the first channel the notes are played normal but the note value (pitch) is stored in a variable. Then on two different other channels this note value should be replace the incoming note value and use this until the pitch changes on channel on. This works so far, but on channel 2 and 3 the Midi on/off messages causes the synth to play more notes as the should. Here is my code so far:

#

#include <RK002.h>

RK002_DECLARE_INFO("Ace Sequencing", "effiksmusic", "1.0")

RK002_DECLARE_PARAM(VOICE0,1,0,16,1); // 0=off, 1..16 = MIDI channel for Voice 0 (Input)
RK002_DECLARE_PARAM(VOICE1,1,0,16,2); // 0=off, 1..16 = MIDI channel for Voice 1
RK002_DECLARE_PARAM(VOICE2,1,0,16,3); // 0=off, 1..16 = MIDI channel for Voice 2
RK002_DECLARE_PARAM(OFFSET1,1,-36,36,12); // 0=off, -36..36 semitones offset
RK002_DECLARE_PARAM(OFFSET2,1,-36,36,-12);// 0=off, -36..36 semitones offset

byte pitch;

bool RK002_onNoteOn(byte chn, byte key, byte vel)
{
bool retval = true; // no process = original note thru

if (chn == RK002_paramGet(VOICE0)-1)
{
pitch = key;
RK002_sendNoteOn(chn, pitch, vel);
retval=false;
}
if (chn == RK002_paramGet(VOICE1)-1)
{
RK002_sendNoteOn(chn, pitch + RK002_paramGet(OFFSET1), vel);
retval=false;
}
if (chn == RK002_paramGet(VOICE2)-1)
{
RK002_sendNoteOn(chn,pitch + RK002_paramGet(OFFSET2), vel);
retval=false;
}
return retval;
}

bool RK002_onNoteOff(byte chn, byte key, byte vel)
{
bool retval = true; // no process = original note thru

if (chn == RK002_paramGet(VOICE0)-1)
{
RK002_sendNoteOff(chn, pitch, vel);
retval=false;
}
if (chn == RK002_paramGet(VOICE1)-1)
{
RK002_sendNoteOff(chn, pitch + RK002_paramGet(OFFSET1), vel);
retval=false;
}
if (chn == RK002_paramGet(VOICE2)-1)
{
RK002_sendNoteOff(chn,pitch + RK002_paramGet(OFFSET2), vel);
retval=false;
}
return retval;
}

void setup()
{
}

void loop()
{
}

#

Don’t mind the „RK002_“ code, it’s part of the library I use.

humble anchor
#

Doesn't the manufacturer have it's own forum? @fickle seal

fickle seal
#

@humble anchor no.

wraith current
#

@fickle seal you need some print statements in there so your can debug and see what exactly is happening.

fickle seal
#

@wraith current a good hint.

wraith current
#

@fickle seal my hunch is that the onNoteOn is getting called recursively

fickle seal
#

mmh, okay.

frozen marlin
#

or a thing that looks like it

proper forum
#

@frozen marlin Voltage Regulators?

#

what's it connected to

north stream
#

That's a TO-220 package, a whole lot of different components look like that, but the most common ones are regulators like Dumfing says, or transistors.

golden lion
#

has anyone worked with refrigerator temperature sensors?

north stream
#

Just the real basic mechanical ones.

golden lion
#

do you know anything about the white GE thermistors?

north stream
#

I know a little about thermistors in general.

golden lion
#

well I have this thermistor from a refrigerator that I'm working with. I'm struggling to find the data sheet. and I'm trying to come up with the steinhart coefficients

north stream
#

Seems like you just need an ohmmeter, thermometer (or known-temperature references) and some math.

#

I haven't ever done it that way, I generally just use a simple quadratic approximation or look-up table to convert a voltage divider reading into a temperature.

golden lion
#

I'll do my best with that. thanks

pulsar charm
#

@humble anchor I'm measuring 0.015V off my fluke but my analogRead is getting me only 0.010

#

any idea what might be causing the loss? I'm guessing it might be impedence but I'm not all too familiar with what that might entail

north stream
#

All sorts of possibilities. I doubt it's impedance, but it could be noise, ground bounce, digit bobble, conversion errors, AC components, reference voltage error, or plain old inaccuracy at that low level.

golden lion
#

@north stream I used excell

#

works good enough

native grove
#

ADCs have a billion things that can cause inaccuracy as madbodger said

north stream
#

Looks like a job for Graphing Calculator or Visicalc, but of course, we all use what we have.

native grove
#

a job for least squares ...

#

the trick with software curve fits is aging over time

pulsar charm
#

STATA!

native grove
#

algebra! 😛

#

2 be fair its linear algebra

#

data science & machine learning is just silly re branding of ancient mathematics

#

neato, i'm actually using that same display on a project XD

pulsar charm
#

Actually I think you could just look for a linear relationship in a log-log scale

#

I know the 0.015 and 0.010 might look like the exact difference between the voltage divider

#

but it isn't that because I'm getting about 0.023 coming out of the sensor itself

#

wait my markings totally flubbed

#

when I rotated the image

#

I'll run it through a digital oscilloscope when I get to work

#

yeah I never really had to bother with the accuracy of small voltages until now

native grove
#

breadboard setups w/ cheapo breakout boards are not a receipe for precision

north stream
#

Oh yeah, I forgot about thermocouple effects: yet another thing that can perturb low-level measurements.

native grove
#

you must design an analog ground to go in tandem with a high precision ADC with a properly buffered voltage reference feeding a properly buffered input

#

taking into account the errors of the buffer systems & voltage reference & ADC offsets...ect

#

then calibrate against a NIST system for offsets

pulsar charm
#

ok I'm taking notes

#

I'll go read up on all this slowly (at work)

#

would there be a plug-and-play high precision ADC that would work well with dev boards?

#

I mean now that I might have to look beyond the onboard ADC

native grove
#

there probably is a true high percision plug&play ADC but i'm guessing your not willing to pay for it

#

If you list the ADC devboard your using & your sensor circuit though, there may be something fundemental that could be causing your error

north stream
#

Depends on the accuracy you actually need. The onboard DAC isn't too bad, but you might have to do some layout tweaks and signal conditioning if you want to measure low levels like that accurately. If Vref is 5V and your ADC is 10 bits, that error is only a couple of counts: it's like 0.1% of full scale, not bad.

pulsar charm
#

@north stream that's a good point.

#

yeah it seems like just about the systematic error I'm experiencing

#

0.0977%

#

I'll see what I can do to try and improve the readings but I won't go too far into it

#

I'll run it through a digital oscilloscope and see what I can do with the signal

dark nest
#

Hey Guys
I need a hand with my PC Not detecting my arduino Uno clone, its a Freetronics Eleven board but im having a issue where if i plug it in via USB its not detected or shows up on My PC or Device Manager.
Also in the Arduino IDE it is not detected and cant find it in the COM Ports. I have attached some photos if they help

dark nest
#

@spice nacelle I've seen this the problem is that my board doesn't show up in device manager and there for I can't give it appropriate drivers

spice nacelle
#

What version of windows ?

dark nest
#

10

#

And it did not instal the drivers when I plugged the board In as it stated it should up the top of that page

spice nacelle
#

Tried different USB port ?

#

(USB2.0 vs 3)

dark nest
#

Yep, different port, different cables
It works fine on my other PC but I need it to work on this new one as it's a laptop and I want it for on the fly changes to code and debugging

#

Yep tryed both types

#

Even with the board not connected to anything/the shields removed

spice nacelle
#

In device manager - select Action > add legacy hardware...

#

Or In device manager: Select View> Show Hidden devices

dark nest
#

It's found the driver and is showing in device managet but it's saying the target device is not found and still doesn't show up on my pc

spice nacelle
#

I am not sure what you mean when you say that it is showing in device manager but not on your PC?

earnest apex
#

hello; has anyone here experimented with pairing an Oculus Go with an Arduino module via bluetooth? I am trying to develop a haptics device that works with the Go, and would appreciate any pointers. I am thinking of using the Adafruit feather nRF52 for this.. (apologies if this is the wrong channel to post in)

humble anchor
#

@pulsar charm yeah, my dad used a potentiometer once. Then he figured out why in Hi-Fi equipment they always use rotary encodes...
Basically analog is very noisy

#

and hard to use

#

That's why I personally prefer all my sensors to be digital.
I see it as outsourcing my problems to someone else

humble anchor
#

What is the max stable baudrate of the USB serial with the SAMD chips?

#

For example itsybitsy m4

humble anchor
#

Hmm, 500 000 Baud seems to run fine

viral creek
#

Anyone had experience creating additional serial ports on Feather M0? I am having an issue where I cannot assign SERCOM5 it looks like the IDE thinks it is the USBSerial but I believe it is unused by default on the Feather M0.......

north stream
#

Several people around here have played with adding serial ports like that, if you do a search on "sercom5", it brings up a few threads.

viral creek
#

thanks @north stream looks like I've got some reading to do from some of those links

humble anchor
#

The last one was like literally a couple days ago

north stream
#

Yeah, seems like a popular issue lately

burnt island
#

baud rate should be a no-op on the SAMD (and 32u4) chips. I don't think there is anything artificially throttling the transfers

fickle seal
#

Hi @wraith current, this was a good hint. With that information I found the error in the code.

wraith current
#

@dark nest a lot of times the arduino clones need a specific driver from the manufacturer because it uses a non standard usb->serial chip.

north stream
#

I've seen five different chips in common use (aside from the boards with native USB support): SiLabs CP210x, Prolific PL2303, FTDI FT231x, CH340G, and the Atmel 16U2 type chips.

solid jetty
#

Whats the fastest update rate I can push to an 80 Pixel length NeoPixel string

north stream
#

I guess if it isn't fast enough, you could have 8 10-pixel strings: if you're driving them with DMA, it'll be 8x faster.

solid jetty
#

I'm now driving them from a single level, which is nice.

#

I've also changed the strip.show() to run less frequently

#

I think I just need to do some value rounding so the stand out values stay lit for a little longer.

#
void audioPulse(int index, int value){
  int wait = 5;
  int red = 0;
  int blue = 0;
  int green = 0;
  int leds = map(value, 0, 255, 0, 78);
if(value < 86){
  blue = map(value, 0, 86, 0, 255);
  green = 0;
  red = 0;
} else if(value > 85 && value <= 130){
  blue = map(value, 86, 130, 255, 0);
  green = map(value, 86, 130, 0, 150);
  red = 0;
} else if(value > 130 && value <= 180){
  blue = 0;
  green = map(value, 130, 180, 150, 255);
  red = 0;
} else if(value > 180 && value <= 210){
  blue = 0;
  green = map(value, 180, 210, 255, 0);
  red = map(value, 180, 210, 0, 150);
} else if(value > 210){
  blue = 0;
  green = 0;
  red = map(value, 210, 255, 150, 255);
}
if(value < lastValue - 20){
    for(int i = 0; i <= 78; i++){
    strip.setPixelColor(i, strip.Color(0, 0, 0,0 ) );
    }
}
for(int i = 0; i <= leds; i++){
    strip.setPixelColor(i, strip.Color(red, blue, green, 0 ) );
    if(i % 5 == 0){
      strip.show();
    }
  }
  strip.show();
  lastValue = value;
}
#

Maybe it would be better if it was a gradient and would change color at X levels but the base levels remained the same color

fading vault
#

So I just got an Arduino for a class project. I used to tinker with them in the past but I've forgot.

#

Now I can't even upload the Blink sketch to the Arduino

#

I've spent the last 3 hours trying to troubleshoot

#

I got all the drivers installed to my knowledge, but even the most basic sketch crashes.

#

Please help because I have to do this project within 2 weeks.

north stream
#

Do you really mean the sketch crashes, or does the compile or upload fail? What messages does the Arduino IDE give?

fading vault
#

Upload fails. A whole bunch of avrdude messaged

#

I restarted my computer but derpdows decided it was time for an update

north stream
#

When your computer finishes updating and rebooting, see if you can copy-paste the first and last few lines from avrdude.

fading vault
#

Alright I will

#

Arduino: 1.8.9 (Windows 8.1), Board: "Arduino/Genuino Uno"

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xaf
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x4c
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x3e
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x81
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xdf
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x70

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#

(I can't find that show verbose output thing in preferences for some reason)

#

I am borrowing this board from my college, and it appeared to be brand new

north stream
#

Looks like you have the port set wrong.

fading vault
#

Oh yeah I was having issues with that. I did something that made the port appear, and it's not showing. The issue is my surface pro only has one USB port so I'm using a splitter. But even if I connect it directly to the port and use the touch screen to upload it, I still get errors.

north stream
#

The same errors, or different errors?

fading vault
#

As you can see it DOES appear in the port menu, but I spent close to 2.5 hours just to get to this point. There's a very good chance I did something wrong. IDK why I totally forgot I'm in this discord, so it didn't occur to me until now to ask.

#

I'll check hang on

#

Arduino: 1.8.9 (Windows 8.1), Board: "Arduino/Genuino Uno"

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xfa
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xfa
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xfa

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#

That's the error message if directly connected

#

It took ridiculously long to upload

north stream
#

Okay, we're getting somewhere. It sees the port and recognizes the board, so the eliminates a lot of possible problems. It may be you have the programmer type set wrong.

fading vault
#

Please explain

#

I'm new to Arduino so I'm not sure what that means

#

It's an arduino uno wifi if that helps

north stream
#

I gathered that from your screen shot. Did you install the MegaAVR board package?

fading vault
#

I think so. I clicked the button for it and it appeared to do it, but then it gave me the message a second time to install it, but nothing popped up.

#

I think it didn't install successfully

north stream
#

Easy enough to find out. Try to change the Board type to "Arduino Uno WiFi Rev2"

fading vault
#

OH that worked!

#

Let me see if Blink works now

#

I uploaded the blink sketch but the LED isn't blinking

#

Do I need a physical LED?

#

as in not the smd one

sinful saffron
#

Hmm, seem to be having a problem with the capacitive touch shield for Arduino https://www.adafruit.com/product/1947 . I wrote code that works perfectly fine on a Uno, but when I try to upload to the Yun, it uploads but doesn't seem to run the program. Is this shield incompatible with the Yun?

fading vault
#

Like I pressed reset and the LED doesn't blink. The orange one does, but not the green one

north stream
#

Okay, I think that means the package was installed correctly.

#

But something else is amiss, that is a truly peculiar error message.

#

Try setting the programmer to something else. Unfortunately, I don't know what the correct one for a Uno WiFi is, but possibly "Arduino ISP" or one of the "AVR ISP" or "USB ISP" choices.

#

As for the touch shield, it uses an SPI interface, which is on different pins with the Yun.

hollow niche
#

Can you upload code through Bluetooth on this?

sinful saffron
#

ah, so even without the shield being attached, it would still error out with the given library

north stream
#

Hmm, actually looks like it uses both SPI and I2C for different purposes. Does the code run at all?

sinful saffron
#

yeah

#

I mean, it verifies

north stream
#

Hmm, it errors out? What error message does it give?

sinful saffron
#

it doesn't "run"

#

it uploads without issue

#

but nothing happens

#

I had though the pinout was the same between the Yun and Uno, with the exception of the serial being used for the bridge.

solid jetty
#

is Serial.Available() limited to a baudrate (I'd imagine it was the rate of the Serial connection, but doesn't seem to be the case)

north stream
#

The pin numbering for GPIO pins is the same, but I think some of the alternate purpose pins (SPI and I2C) may be in different places. Since I think this shield uses both, it may be worthwhile writing some simple test programs to try one thing at a time while figuring out the wiring.

#

I thought Serial.available() just checked to see if any characters had been received and were in the buffer. I don't see how it would depend on the serial clock rate.

sinful saffron
#

the pinout looks identical just looking at them side by side. They both run the same 328 I believe as well. Though you might be right about them moving the functions

#

I'll put the display on the Yun with the bare minimum code and test that

north stream
#

I thought the Yún used a 32U4 instead of a mega328.

sinful saffron
#

you're right.. lol

#

still, was hoping it would be a drop in replacement

#

with the CapTouchPaint example, the touch input functionality works but not the display

fading vault
#

When I change the board type to the one labeled "Arduino Uno Wifi" it has the similar errors

#

The only one that works is the Rev 2

#

And even that doesn't give any visible output on the board. I'm going to see if I can dig up my own old arduino to see if that works.

#

Oof I can't find it. I'm going to look again and contact my teacher tomorrow. Maybe if I brought my computer and the arduino into his office, he could help troubleshoot it.

solid jetty
#

Does anyone know a decent amount about Baudrate?

north stream
#

I do, but possibly not in a form that's useful to you (like how to use a Motorola MC14411 Bit Rate Generator)

barren scaffold
#

@solid jetty might as well ask the specific question about baud rate. Either someone can get you toward the answer now, or might see it later.

north kelp
#

@solid jetty I can't imagine Serial.available() operating at any other baud rate than I specify in Serial.begin(xxxx). What are you making?

solid jetty
#

I actually figured it out, it was an issue with my render loop. @north kelp I'm making a case lighting that is controled via audio through WASAPI data from the PC. I posted it in #show-and-tell

north kelp
#

Oh cool. Congrats!

sinful saffron
#

Looks like I have to cut and reroute/solder some jumpers. It says to do that for the Leonardo board, which uses the same CPU as the Yun, so hopefully that'll work

north kelp
#

Probably moving the I2C SDA and SCL pins, right?

sinful saffron
proper forum
#

Are the feather m0's input pull-ups enabled by default?

fading vault
#

What's the best online learning tutorials for Neopixels for someone that knows Java but doesn't know anything about Arduino?

north stream
fading vault
#

Thanks

past token
#

Can someone help me understand this example code for the PM2.5 sensor?

#

There is this specific function called readPMSdata that I don't quite understand

crystal mesa
#

Got a link to the code?

#

Assuming line 31

#

so it's passing the address of the variable pmsSerial to this readPMSdata function

#

pmsSerial is set up in lines 8 and 9 as SoftwareSerial (or hardware in line 3)

#

and then readPMSdata is defined in lines 55 through 103

past token
#

@crystal mesa Yes it is!

crystal mesa
#

it's a character stream and it's looking through the stream returning false until it hits 0x42, which signifies the start of the output from the sensor, I guess

#

Would need to check the datasheet to be sure

past token
#

I have a link to the data sheet

#

Look at page 13

#

I'm not too familiar with reading data from streams in C, that's why I wanted to ask

crystal mesa
#

but once it find that character, it reads the next 32 bytes in the stream into a bugger and then performs a checksum on it

#

and then fixes the endianness of it, copies the data back into a pms5003data struct, and hands it back

past token
#

0x42 is 66 in decimal

crystal mesa
#

which is capital B

past token
#

hmm interesting

crystal mesa
#

Yup on the table on page 13

past token
#

I'm just not too familiar with some of the syntax in that function, so I need to review

crystal mesa
#

the start character is 0x42 ("B") followed by 0x4d ("M")

past token
#

For example, the -> operator is used, and there's also some memory management functions being called (read(), available(), readBytes(), buffer, memcpy())

#

Any reason the start character is 0x42?

#

Or is it just arbitrary?

crystal mesa
#

the first two bytes are always BM

past token
#

Why is that?

crystal mesa
#

I have no clue

past token
#

Interesting

crystal mesa
#

but that's what it says in the datasheet

#

but, that's what it's doing

past token
#

Thank you for your help!

crystal mesa
#

it looks for 0x42, then reads that and the following 31 bytes, calculates the checksum to see if it matches the checksum in the data, then turns it into a struct in memory for you to work with

past token
#

Do you understand what this is doing?

// The data comes in endian'd, this solves it so it works on all platforms
  uint16_t buffer_u16[15];
  for (uint8_t i=0; i<15; i++) {
    buffer_u16[i] = buffer[2 + i*2 + 1];
    buffer_u16[i] += (buffer[2 + i*2] << 8);
  }

  // put it into a nice struct :)
  memcpy((void *)&data, (void *)buffer_u16, 30);

  if (sum != data.checksum) {
    Serial.println("Checksum failure");
    return false;
crystal mesa
#

no problem, it was kind of a fun bit

#

I understand what it's doing, but not by reading the code

past token
#

Also what is the purpose for the checksum?

#

Sorry for asking a lot of questions btw, I'm used to Python programming and not working at this low level 😛

crystal mesa
#

the first bit is making sure that whether the host system represents data as little-endian or big-endian, it's properly represented

#

Do you know about little/big-endian?

past token
#

I googled it and read a little about it

crystal mesa
#

Some hardware goes one way, the rest goes the other

past token
#

to my understanding, some data can be read left to right, or right to left

#

the little end comes first, or the big end comes first

crystal mesa
#

basically

#

so that first chunk is making sure that the data read off the serial (which the sensor sends only one way) is properly represented for the underlying system hardware

#

That loop is using an unsigned 16-bit integer (two bytes)

#

as a buffer

#

so somehow it is swapping the order of the bytes -- reading those two lines still is above my knowledge of C

#

I'm not sure how it knows how to/if to swap them

#

OH...

#

that's clever

past token
#

i wish i had your epiphany 😄

crystal mesa
#

Okay, what I think it's doing is it creates a buffer of 16 uint16 (0 - 15)

past token
#

Yes I see

crystal mesa
#

so previously in line 71-73 we took the 32 bytes read from the serial object to a uint8[32] buffer object

#

so it's taking two characters out of the 8-bit bufffer, multiplying the "high" one, and adding the "low" one so that they make a 16-bit integer that corresponds to the two 8-bit integers

#

and then loading that into the spot of the 16-bit buffer

past token
#

Oh my goodness

crystal mesa
#

so you start with 32 8-bit integers that are paired and end with 16 16-bit integers

past token
#

That is quite clever

crystal mesa
#

and so the data is then stored according to the system's endianness because of how the lower level code handles representing multi-byte characters

past token
#

🤯

crystal mesa
#

and then 95 copies that new 16-bit buffer into the memory location of the pms5003data struct (called data)

#

and then it double-checks the checksum in 97-99 to make sure what we calculated off the wire matches what was calculated by the sensor

#

if they don't match, we return false, if they do, we return true

#

so this function doesn't pass the data in and out per se, but if it successfully reads the bytes and the checksum matches, it returns true to let the outside code know the struct has been updated and you should look at it

#

so it avoids having to have multiple copies of data in and out

past token
#

yes thats what i was able to infer from that, essentially it just keeps updating the struct pms5003data

crystal mesa
#

yup

#

very fast, clean, low on memory usage

#

perfect for a microcontroller

past token
#

getting involved with hardware on this low level intrigues me so much

#

but there is a lot of overhead

#

i need to step up my C skills

crystal mesa
#

I hear ya

past token
#

but you did do a great job at clearing this up for me

crystal mesa
#

playing with Arduino is the most C I've ever done and I started trying to learn C back in the Turbo Pascal/Turbo C days

past token
#

so i do thank you 😄

crystal mesa
#

hey, I learned a few things too

#

it's like working a puzzle

past token
#

embedded systems would be the next step after arduino programming

crystal mesa
#

you get a piece here, a piece there, keep at it and soon enough you have the big picture

past token
#

i'm going to have to mess around with a couple of functions

crystal mesa
#

enjoy!

past token
#

thanks again @crystal mesa 😄

crystal mesa
#

anytime!

past token
#

Does anyone know if it's possible to send GET requests using an Arduino UNO?

#

there is no wifi module hooked up

#

I was hoping I could use the USB port for data transfer

burnt island
#

not directly. You'd have to have something on the other end of the USB to handle all of the networking

past token
#

Ah I see

#

Any recommended hardware for wifi capability?

burnt island
#

you could go with a esp32 directly, though they're a little quirky. There's the Particle Argon too with a different toolchain

past token
#

interesting

#

that could work for an Uno

#

what about a Micro?

north stream
#

The AirLift? It should work with anything that can act as an SPI master, but I don't know offhand if the existing libraries support the Micro (or soft SPI, if you end up wanting to use other than hardware SPI for whatever reason).

bold saddle
#

I've got a brand-new fresh out of the box PyGamer and on trying to use it in Arduino mode with the program "arcada_pygamer_test" in the example code. I'm pretty sure I've installed all of the libraries as explained in the learning guide. But when I tried to compile the sketch I get
"C:\Users\Chris.cy\Documents\Arduino\libraries\Adafruit_Arcada_Library/Adafruit_Arcada.h:264:39: fatal error: Adafruit_SPIFlash_FatFs.h: No such file or directory"

daring marsh
#

arcada is undergoing a refactor right now

#

try again on monday!

past token
#

any tips/resources for programming embedded systems?

#

i would really like to take a peek under the hood of the arduino

#

looking at the Arduino.h source file might be a good place to start

north stream
#

It's all open, so you can look at all the pieces.

#

You can look at the wrapper that calls setup() and loop() and see what they do.

past token
#

that sounds like fun

#

i'm assuming these functions are defined in Arduino.h?

north stream
#

There's also a toolset with goodies like avr-size and avr-nm that let you see what the pieces of the compiled program are and how much room they take up.

past token
#

I would also like to get involved with memory management and reading/writing to streams

north stream
#

You can also get the compiler to give you an assembler listing of what it compiled from your sketches.

past token
#

so just compile a file using gcc with the -s flag?

north stream
#

I think it's -S, but yeah: turn on "verbose", grab the compile line, and replace "-c" with "-S"

#

If you drill down to the "ldscripts" directory, you can see how the memory is laid out (I ended up making a custom memory map for one project and learned a lot in the process).

#

Arduino.h pulls in a bunch of stuff, and a bunch of other stuff is also done automatically and invisibly, but all the pieces are there.

#

The main program is called main.cpp, it's only 52 lines long, and the heart of it is just what you'd expect: ```c
setup();

for (;;) {
loop();
if (serialEventRun) serialEventRun();
}

#

This, incidentally, shows why if your code never exits loop() you can have issues with serial connections 😃

past token
#

I feel like most of my knowledge when it comes to embedded/low-level programming is scattered. I suppose I'm looking for a tutorial series, or some reading material that provides a more structured introduction to working closer with hardware?

#

There is something satisfying, yet mind boggling with how computers work underneath the hood.

north stream
#

Hmm, I don't have any concrete recommendations, unfortunately. You can download the Atmel IDE and program the AVR directly.

#

I learned on an ancient 6800 system with 768 bytes of RAM, so I had to hand-assemble my code and necessarily work closely with the hardware. That experience has paid off repeatedly ever since.

#

These days, there is a choice of small CPUs and MPUs you can use, with nice tools that will let you watch your program execute, an instruction at a time: seems like a great way to learn.

mild elk
#

I have Ben's CPU on my desk

mild elk
#

I mean, it's not an exact copy, I mnie moified it quite a bit

random oyster
#

Ooh, I've been meaning to take a look at Ben Eater's videos, they seem very interesting!
If you're looking for books, I can give a few recs. I'm reading Practical Electronics for Inventors (P. Scherz, S. Monk) right now and I'm loving it. It takes you all the way from relatively low level physics concepts up the layers of abstraction to circuit design and whatnot. I also love that it's not as disjunct as learning in uni where I'd go from a physics course to circuits/electronics with totally different profs 😄
Making Embedded Systems (E. White) was a good read, it gives a decent high level overview of several embedded systems concepts and is a good intro to the topic.

mild elk
#

Thanks! I'll check them out. Definitely watch Ben's videos, they are really good. Maybe You even decide to build Your own copy of his CPU. Or maybe do some modifications like I did.

random oyster
#

yeah, the cost of parts initially held me back but it'll probably be a worthwhile investment since I've been wanting to get more into computer architecture. have you read the book he suggests? Digital Computer Electronics I think, that might have to go on my wishlist too 😄

mild elk
#

No, I haven't, but I also wanted to have a look into that

#

Ben sells ready to assemble kits on his website, but I sourced parts myself and it about half the price of a kit.

#

If You decide to source parts yourself, I recommend You to use HCT series ICs where possible because it will reduce power consumption.

random oyster
#

that's true, I think his website referenced a lot of amazon links, I might be able to save quite a bit if I add it to a large digikey or mouser order. thanks for that recommendation, I'll have to keep that in mind! I'm pretty unfamiliar with 74xx logic chip families that that's good to know.
out of curiosity, what kind of modifications did you make to the CPU? if you don't mind sharing of course rooAww

mild elk
#

So first thing I did was replacing RAM with ROM. This way I don't have to program it every single time I power it on, but I have to use external programmer if I want to change the code. The tradeoff is that currently I have no ram so can't execute instructions like STA, but I want to add 256 bytes in the near future. I upgraded program counter to 12 bits and got rid of memory address register. I'm using 28C64 EEPROM, and when CPU wants to read the data, it drives A12 high and reads the same address as the instruction. This way my program can be 4096 instructions long. I removed output function from B register becaues I coundn't think of practical use for it. Also I multiplex some control signals using 74LS139 to save microcode ROM outputs. And last but not least, i made it execute every command with 4 clock cycles. This way it's 50% faster that Ben's CPU at the same clock speed and takes up 3 less breadboards.
I can teach You a bit about 74 series if You want.

#

If You have any questions feel free to ask

#

I can post pictures as well

north stream
#

I'm thinking doing something similar, but using an FRAM chip wired so some of it acts as RAM and some as ROM: then I can write code to it, then disable writing to that section and it will hold it for me.

mild elk
#

Just checked and oh my god this is expensive

#

Looking at FM16W08

#

It would be pin-compatible with 28C64

#

But I would still need to integrate programmer into my board which I currently don't have space for

north stream
#

That's the nice thing about the FM16W08: it doesn't need a programmer, you just write to it like RAM and it's magically non-volatile.

past token
#

Reading the docs, it seems that they've provided a math formula for determining power consumption and sensor resistance

#

My question is how should I go about actually reading data off the sensor?

#

Apologies if it's a newbie question

daring marsh
#

@past token check "Basic Measuring Circuit:" and then use an analogRead() to read the Vout voltage

past token
#

@daring marsh Thank you! It's been a while since I've messed with Arduino

vital drift
#

i have that one.. it's a pretty good sensor.

past token
#

@vital drift Oh cool!

#

How accurate would you consider its readings to be?

frozen marlin
#

Hi guys. I have a sparkfun Soil moisture sensor and I'm just wondering how I could place a potentiometer in between

#

I know this won't work but I'm not great with electronics

wintry berry
#

hi

#

someone here know about neopixels?

#

colorWipe(strip.Color(0, 255, 0), 50); // Green

#

what the 50 mean?

#

this is from here

#

line 62

native nova
vital drift
#

@past token How accurate? I don't know, unfortunately. If I remember correctly, it's reactive to numerous things (it's a general AQ sensor?), which makes it hard to judge accuracy unless you have a test chamber, sample gasses, etc. .. which isn't worth doing unless you're trying to detect and calibrate for a single contaminant and you're sure it'll be exposed only to it. I did, however, feel like it was generally a good sensor for monitoring AQ - it responded as you would expect it to based on what was going on in the environment. Cooking, use of chemicals, etc. sent the readings "higher", and fresh air brought them back down.

north stream
#

@frozen marlin I'm not sure what you wanted the potentiometer to do, but on the assumption you want it to scale the reading, hook one end to ground (black wire), the other end to the output of the soil sensor (right hand end of green wire), and the wiper (middle) to the Arduino input (other end of green wire). The red and black (power) wires hook to the soil sensor power inputs as usual.

fair void
#

Hey do you know any RFM96 libraries for arduino ? RadioHead is too ram hungry for my project

#

I've found LoraLib on github but it can't communicate with the Adafruit RFM9x library on my raspberry pi 😢

proud meadow
#

Hello 😃
Is there a way to flash an arduino-sketch directly onto a Feather M0 via SWD, so it starts instead of the bootloader? I tried by exporting it to a .bin-file and flash it via a J-Link-debugger but that kind of bricks the feather, it doesn't do anything after doing so 🤔

long sphinx
#

Anyone dealt with an ESP32 waking from deep sleep just fine when hooked to usb, but won't wake when running off of battery?

fleet pewter
#

Maybe the battery has a low current cutoff that's interfering?

#

If it's a lipo

idle magnet
#

Rephrase. I have bad Arduino IDE code on my Gemma M0. I try to upload new code, but get a port busy error half the time and an endless Uploading... loop the other half. Pressing the reset button brings me back to square one. How do I be able to upload new code to my device? A full reset seems like it would work but I don't know how

#

problem solved, i needed to catch it in the window i had as a delay in code

proper forum
#

are any arduino's fast enough to read neopixel signalling

burnt island
#

once you catch the start sync I imagine it would be nearly the exact code as sending.

proper forum
#

I mean the sending code for Arduino on many devices is assembly with a bunch of noops

#

Whatever device it is would need to read and store the timings on a microsecond timing scale

#

Maybe an m0 or m4?

buoyant sluice
#

I've managed to persistently store data to the Trinket M0 memory using Circuitpython but is there an 'Arduino way' of doing the same thing?

hidden oracle
#

did you try EEPROM.write / read?

buoyant sluice
#

No EEPROM on a Trinket M0 (they use the SAMD21 chip)

hidden oracle
#

ah, i see... SAMD

buoyant sluice
#

But this can be done with CircuitPython, so I thought there might be a way of doing this with Arduino code?

north stream
fair void
#

Hi, How I can upload some code to my adafruit feather 32u4, when I try to upload from my Windows PC, click on the reset button just after the end of the compiler, the feather say that the detected com port is not connected

bleak glacier
#

@fair void You may need the Windows Drivers loaded and try the rest of the steps in the guide. https://learn.adafruit.com/adafruit-feather-328p-atmega328-atmega328p/arduino-ide-setup Other things to try is to use a different USB cable as some are charging cables only and plug into different usb ports on the pc. USB 3.0 on newer computers brought some issues using the IDE so hopefully you have a older USB 2.0 port or older USB2.0 hub to pass through to the pc. Good luck.

Adafruit Learning System

Classic ATmega328p tech with the new modern Feathers

north kelp
#

@bleak glacier You're pointing at the product guide for the Feather 328P; @fair void has a 32u4.

#

@fair void Which specific Feather 32u4 are you working with? Adafruit has several. Can you link or provide the product number to the exact one you bought?

fair void
#

I can upload with arduino version 16 @north kelp @bleak glacier

north kelp
#

@fair void What do you see when you choose Arduino > About Arduino? The current stable version of the Arduino IDE is v1.8.9.

fair void
#

I h1ve tried on 18.9 but it doesn't work and on 16.13 it works

bleak glacier
north kelp
#

@fair void That version number doesn't look right. Can you post a screenshot of your Arduino > About Arduino dialog? Where did you install the Arduino IDE from?

fair void
#

I'll do that

#

I've installed arduino from the old release page and it works better than with arduino 18.9 @north kelp

#

@bleak glacier thank you I'll check that

north kelp
#

What OS are you running?

fair void
#

Windows,It doesn't work on minux

#

Linux*

north kelp
#

Windows version...?

fair void
#

Oh I've just seen my typo: I'm on arduino 1.6.13 not 1.16

#

Windows 10

north kelp
#

That sounds better.

celest finch
#

Howdy folks! I'm using the sparkfun MPU 9250 with their provided library, but there is a lot of yaw and roll drift, and I'm out of my depth here! Any help is greatly appreciated 😅

fair void
#

@celest finch you don't have any pitch drift

celest finch
#

Doesn't look like it.

wet crystal
#

Tell me if this is in the wrong category

#

I forgott the password for the bios of my tablet

#

Now I want to reset it

#

Opened it up and found the bios chip

#

Just wanted to know if someone can approve this information

north stream
#

Hmm, pin 2 is the data out pin: short-circuiting it could damage the pin.

#

Looks like there are "dogbones" in several traces, you could use one of those as a solder jumper. I'd probably use the !CS one (pin 1), as it looks easiest to get to, not as timing critical as most of the other signals, and won't cause problems with Dual or Quad SPI (if used).

wet crystal
#

Couldn´t I just push a jumper wire against the pin

#

Instead of soldering

north stream
#

I'm not sure what's driving CS, you don't want to burn that either.

#

But you could just try shorting the pin and hope for the best.

wet crystal
#

What do you think how high could be the risk of damage

north stream
#

Safest way is to boot it in maintenance mode. Second safest is cutting (and then later resoldering) the trace. Next safest is shorting DO0 (pin 2) to ground (pin 4). Next safest is shorting !CS (pin 1) to Vcc (pin 8).

wet crystal
#

I looked up on the internet and didn´t found a solution

#

It just doesn´t let me in bios and there is no option to reset that

north stream
#

Plug in external keyboard, power on while holding left shift key, click on "troubleshoot", then click on "reset" (clear completely) or "refresh" (re-install).

wet crystal
#

I try that

#

But what i read was that its part of an anti theft system

#

And that even vendors have to change the motherboard

#

No way

#

Maybe I forgott to mention, that I have acces to windows if there is another solution

north stream
#

You have the login password but not the BIOS password?

wet crystal
#

Right

#

I set it, it isnt even a secure one

#

But I cant remember

north stream
#

How do you boot it up if you don't have the BIOS password?

wet crystal
#

Even made a list with passwords i tried

#

I dont have to enter, when I dont want to acces bios

north stream
#

Not a very good "anti theft" system. I'm not sure what your problem is then.

wet crystal
#

It is secure if you mix with a bitlocker

#

Thats how it is meant

#

So what should I do to get the bios password away

mild elk
#

I'm trying to parse a big json on ESP8266 with limited success: my problem is that dynamicJsonDocument can't be bigger than aroun 9000 and my json does not fit into that

celest finch
#

@fair void Another issue: the pitch "sticks" to 0

#

when rotating at a constant rate past 0, it sticks to 0 for a second before quickly correcting

north stream
#

I don't see how it's secure if you can fire up windows. I'm not sure what "mix with a bitlocker" means.

#

In any case, try shorting pin 2 and see what happens. Worst case, you burn the chip and have to replace it. Best case, it lets you re-install BIOS.

barren scaffold
#

So if that chip happens to be associated with the TPM, I'd be worried about losing whatever encrypted data is on the drive. If you've got a verified backup, that's less of an issue.

wraith current
#

@mild elk maybe go to Raspberry Pi ? It's better at large amounts of data.

mild elk
#

I wanted to keep that as small as possible. I am properly getting the json and parsing it, the problem is that I don't get all the data I need because dynamicJsonDocument is too small

wooden bobcat
#

can anyone point me to sample code for the samd51 (grand central) to do PORT reads of parallel data? i’d like to read a minimum of 11 bits, but up to 21 or 22. i’ve done 8 bit parallel reads on the uno, but am hoping i can grab more bit at a time with the grand central. i’ve got the samd51 docs—some sample arduino code if available would help me understand all this. i’m interfacing to a 1980’s computer... any pointers appreciated!

sick latch
#

Hi! I'm hoping to use the 8266 huzzah breakout to read from an i2c sensor, and write to an SD card over spi.

Although the Adafruit tutorial does not mention spi pinouts, the datasheet for the esp12 seems to suggest that GPIO14 -> CLK, 12 -> MISO, 13 -> MOSI, 15 -> SS.

Can anyone confirm if these are the correct spi pinouts?

barren scaffold
wooden bobcat
#

@barren scaffold thanks for the link! this actually got me thinking about doing another project! i’m more interested in working at the register level so i can read multiple bits at a time very quickly. i’ve done this before with another processor, but this one is a bit more complex, which is why i was hoping that some sample code was around to look at. i did find some for the samd21 and that helped. as CRTs and their driver boards are failing and repair parts becoming difficult to source, my project is to snoop video memory and recreate the display on flat panel or a terminal emulator. i can already do that to an extent, but i have to be faster.

north stream
#

That sounds worth doing. Granted, I'd rather design CRT driver boards than flat panel driver boards, but it's getting harder to find the CRTs themselves and some of the higher-voltage support components.

wooden bobcat
#

@north stream it’s a fun project. flybacks and horizontal output transistors are tough. the hard part is getting the data and knowing where it goes on the screen. i know how to sync it up. once i can reliably get the data i’ll use something like a pi to serve it to a hdmi device or make it network available for headless.

north stream
#

I have a stash of surplus flybacks, but I'm also looking at using CCFL transformers to make HV. Sampling video data is a whole adventure of its own.

wooden bobcat
#

the crtc and some external logic i put together is doing a lot of the work for me. ccfl for hv. that’s interesting. the scarcity of hv mosfets is another problem.

burnt island
#

@wooden bobcat PORT reads should be pretty much the same as on the Uno, but 32-bits wide instead of 8.

wooden bobcat
#

thanks! i try to make things more difficult than they often are... 32 bits is a luxury.

kindred knoll
#

Hello ! can I use TinyUSB to have my Feather M0 behave like a MIDI instrument ? I was using the MIDIUSB library by Gary Grewal but It doesn't work anymore. many thanks

proper forum
#

What options are there for powering ws2812b's from a battery powered feather?

#

Collecting them to 3v3 would be preferred since it allows power switching with an en pin but the ws2812b supply voltage only is rated for 3v5

north stream
#

You'll probably get better luck by connecting the WS2812B string directly to the battery (assuming the battery is an appropriate voltage). You could switch the power to the LEDs by either simply setting all the LEDs to dark, or using a transistor.

celest finch
#

I'm using the sparkfun mpu9250 and the pitch seems to stick to 0, and I have no idea why. I'm just getting an image of the graph real quick

#

before the first red line, the sensor is tilted 90 degrees forward

#

between the two red lines, I rotate it 180 degrees quickly and linearly

#

the pitch "sticks" to 0, then takes a while to realise it's actually moved further?

humble anchor
#

For example setting resolution and frequency for pwm?

north kelp
humble anchor
#

I'll check it tomorow

random oyster
#

is there an Arduino samd51 repo I'm missing? The "SAMD" repo seems to be only for the samd21.

inland crag
#

it's both

#

ArduinoCore-samd is samd51 and samd21

#

at least the adafruit version is

#

maybe you're looking at the arduino one?

random oyster
#

ahh, yes you're right, I didn't realize adafruit has its own fork 😄

#

thanks!

humble anchor
#

Hmm seems that only teensy and esp32 can easily set their pwm frequencies

north stream
#

It's not that hard, just writing some magic numbers to some registers (you can generally still use analogWrite() as usual after this). ```c
TCCR2B = TCCR2B & B11111000 | B00000001; // for PWM frequency of 31372.55 Hz

north kelp
#

Ohhhh… PWM frequencies. Misread your question, @humble anchor. Thanks, @north stream

proper forum
#

how much difference in power consumption is there between the various basic proto feathers

half warren
#

Hello. I'm using a Trinket m0 to run code meant to interact with a PS2 Mouse device and I cannot use the serial monitor like I would have expected. When it is opened the device is no longer recognized and must be reset. Does anyone have any tips?

north stream
#

I think the serial port gets re-used for uploading code, so you have to re-connect after uploading. I'm not sure if that's what you're seeing or not.

long sphinx
#

Currently writing BMPs to an ePaper, can't seem to find any decoders for PNG or non-animated GIFs, anyone doing this at the moment?

north stream
#

There's a passable GIF decoder I've been using for a LED panel, but it's also for animated GIFs.

upbeat night
#

Can someone help me fix the arduino IDE??

long sphinx
#

Are you using static GIFs or animated ones?

proper forum
#

@upbeat night what's the issue

fallow harbor
#

If I place a TFT shield on my Uno, what are my options to connect other devices like sensors to display the temperature for example onto the TFT display?

humble anchor
#

@north stream Hmm, yeah but I don't know if the Uno is fast enough for what I'm doing.
The original arduino sketch used pins registers instead of digitalWrite because that was to slow

north stream
#

I don't know what you're doing, I just noticed you were asking about faster PWM frequency.

indigo apex
#

Hello, I have an rtc and i am wanting to take a reading from a sensor every 500ms. I understand I can do it via a delay but that is not very accurate due to the unknown of how long a function takes. I would like to initialize the loop every 500ms and regardless if the function takes 10 or 400 ms it will start back up again 500ms from the last start. What is the best way of handling that?

#

(I am using a DS3231 and an arduino pro mini) - please at me if/when you respond, im still trying to figure it out on my own, thx

north kelp
#

@indigo apex For one-second intervals, you could use the SQW pin, and call writeSqwPinMode(Ds3231SqwPinMode mode) with DS3231_SquareWave1Hz.
I'd connect that SQW pin to an interrupt-capable pin – pin 2 or 3 on your Arduino Pro Mini, and use attachInterrupt() to catch that signal.
I'd use the Arduino's millis() to determine the half-second events.

indigo apex
#

Can you please elaborate on the millis() command?

north kelp
#

millis() uses the Arduino's own internal clock to tell you the number of milliseconds since the program started.

indigo apex
#

so i could do a delay(500-millis()) to run it again?

#

for the second run for that second?

north kelp
#

I'd not use delay(). Instead, I'd look at millis() every time through the loop, and decide whether it's time to act.

indigo apex
#

on the same page

#

so basically it is looping through each time and decreasing the remainder and once it finally has no(or negative) remainder it runs?

north kelp
#

It's basically doing what we'd do if someone asked us to tell them when 5 seconds are up. It's recording the current time in a variable, say 12:27:04, and the interval, 5 seconds, and checking to see whether it's 12:27:09 or later.

indigo apex
#

👍

#

i think that will work

north kelp
#

How accurate does your 500ms sampling have to be? What are you making?

indigo apex
#

flow monitor for water hammers.

north kelp
#

What sensor are you using?

indigo apex
#

based on my math, their formula for kPA is not right, but i fixed it in my version.

#

(im dealing with psi, and i have it within a psi at 100 psi, so im good.)

north kelp
#

Sweet!

indigo apex
#

the fun part is dealing with the logging

#

im doing a log of every 5 min regardless

#

but if a hammer is noticed, log continuously for 5 min every 1/2 second

north kelp
#

Cool

#

Where are you logging your data to?

indigo apex
#

microsd card

#

via csv

#

I hope to opensource it once i am finished.

north kelp
#

How much space do you need for your log, typically?

indigo apex
#

still in the programming stage, 3505 lines is 155kb

#

i have an 8gb card atm

#

i dont expect to have to use all 8gb

#

i think i can send the data via text every month via
https://hologram.io/

Hologram

Cellular Connectivity for the Internet of Things

#

ill see if i can get to that point, eventually

#

i have to make it last a month first.

north kelp
indigo apex
#

no, looking now 😃

#

which SIM card chip/board?

north kelp
#

It works with pretty much any board that can connect via Wi-Fi or cellular.

#

It's a back-end service.

indigo apex
#

what board do you recommend from Adafruit?

#

(still shopping around)

north kelp
#

It has 256K of RAM, whereas your Pro Mini has 2K, so there's a lot more room for your code to grow.

#

It also has both Bluetooth LE and LTE Cellular.

#

And it has an on-board 2MB SPI flash, so you might be able to get rid of the SD card.

indigo apex
#

other major factor is power.

#

right now i have 3-18650s and we guess that will last a whopping 9 days.

#

(thinking we are going to add solar panel, maybe)

north kelp
#

Maybe a water turbine generator?

indigo apex
#

#gobigorgohome

#

@north kelp Thank you for your help!

north kelp
#

(All Feather MCU boards include charging circuitry, and automatically switch between power sources.)

patent marsh
#

How difficult is it to make custom boards Arduino IDE compatible? Has any non Adafruit employee here done this?

daring marsh
#

@patent marsh its extremely hard if the chip is not already supported thru a board support package (e.g. atmega328 or atsamd21)

#

its easy/medium if the chip is already supported and you just need to make a varient

faint adder
#

does anyone know how to take info from visual studio code and have it go through the serial monitor? (to be read by an arduino)

barren scaffold
#

What kind of "info" from VS Code? And whose Arduino serial monitor? One in the IDE?

north stream
#

On the other hand, custom boards built around chips Arduino already supports aren't that tough. I've done ATmega328 boards and MSP430 boards (using the "Energia" port of Arduino), and customized pinouts, memory maps, etc. as needed.

faint adder
#

@barren scaffold can I DM you about it?

barren scaffold
#

Prefer not, since others might have better answers. And it’s getting late for me.

faint adder
#

Ah ok

barren scaffold
#

But a description of what you’re really trying to accomplish would help.

faint adder
#

I'll make a post here later as my PC is currently off, but the main part is using the assetto corsa shared memory to Arduino I have a example that pastes the info to a console application but I'm wondering how to take it to the Arduino, for a rpm metre or something like it

#

I thought about using simhub but idk I that works properly for me and this has started to work a bit but I'm not sure how to work with C++

#

I can post the example project here if needed

barren scaffold
#

Is “pastes the info to a console application” a fancy term for “uses printf, cout, scanf, or cin”?

faint adder
#

Well yeah it prints it to the console application or whatnot

#

I'm not sure how to explain it

#

Well this is what is showing (well a bit of it)

#

---------------PHYSICS INFO---------------
packetId : 88647
gas : 0
brake : 0
fuel : 30
gear : 1
rpms : 2100
steerAngle : 1.4013e-45
speedKmh : 0.00456113
velocity : -0.000280811 , 2.12083e-06 , 0.0017243
accG : 0 , 0 , 0
wheelSlip : 0.0580643 , 0.0620075 , 0.0432734 , 0.0256657
wheelLoad : 3163.94 , 3239.9 , 3584.79 , 3576.37
wheelsPressure : 21.1136 , 19.9705 , 20.5739 , 20.1084
wheelAngularSpeed : 0 , 0.00780772 , 0 , 0
tyreWear : 100 , 99.9232 , 99.9666 , 100

barren scaffold
#

And that’s your code that prints all that?

faint adder
#

No

#

It's the example from the person who posted it

#

I've been using that to understand it

barren scaffold
#

So that’s something you have source code for?

faint adder
#

Yes I guess, well I'm not really sure as I don't know much about all this

#

I have all the code that is needed from visual studio to build the exe which in the end receives the info from the game and prints it to the console

barren scaffold
#

Then, yes, you have source code.

faint adder
#

ok

#

my understanding (which may as well be wrong even if its correct) is i should be able to add some code to this that instead of the printData line, will send the certain data to the serial port i have assigned for my arduino so i can then have that displayed

#

this is what i found for that

barren scaffold
#

Haven’t read that one, but https://blog.manash.me/serial-communication-with-an-arduino-using-c-on-windows-d08710186498 should show both the Windows and Arduino side of things. You may want to start with something as simple as sending an ‘A’ turns on an LED, and sending a ‘B’ turns it off.

Medium

If you’re acquainted with arduino, at some point you needed to establish serial communication between a pc and the arduino. There are a lot…

faint adder
#

thats the code in a txt

#

the whole of one section that gets send to the console is too much for discord to send

faint adder
#

@barren scaffold ive swapped to C# at request of a friend as there is a library .dll that i can use for the sharedmemory part that should be easier to use

#

and i can send and read data

#

using another program

#

now for the harder part

#

(it will be going to arduino in the end but this is just for testing)

faint adder
#

ok alot has changed now

barren scaffold
#

C# is one way to get it done. If you have better support from friends and others with that over C/C++, use that. Lots of ways to get there, just have to pick one and stick with it until you know enough to say if there are better future options.

heavy mesa
#

So I just got my 2" ISP TFT and I'm having trouble with the display mixing up x and y.

#

I'm using the Adafruit_ILI9341 library.

#

Example 'ShieldLI9341`.

north stream
#

There's a setRotation() method available

#

The graphicstest example uses it

heavy mesa
#

Thanks.

eager jewel
serene magnet
#

hey peeps, could one of you tell me whats wrong with this code? It says "error compiling for board arduino/genuino uno"

#

im never good at this

eager jewel
#

At a glance, it looks like you have an extra closing brace at the end.

spice nacelle
#

@serene magnet delete the curly brace under the line
vin=0.0;

#

You have 4 lines outside of loop()

#

By deleting the curly brace. It should compile.

wraith current
#

So I have this declaration/construction defining my oled display but I want to do it inside of conditional logic but I can't figure out where to put it so that it's in global scope. Ie. i'd like to put it somewhere inside of setup and but have it also in scope of loop.

#

#ifdef UPSIDEDOWN
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R2, /* reset=/ 16, / clock=/ 5, / data=/ 4);
#else
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /
reset=/ 16, / clock=/ 5, / data=*/ 4);
#endif

#

i'd rather do
void setup() {
if (upsidedown) {
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R2, /* reset=/ 16, / clock=/ 5, / data=/ 4);
} else {
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, / reset=/ 16, / clock=/ 5, / data=*/ 4);
}

wraith current
#

nevermind. u8g2.setFlipMode(1) rotates the display after construction.

random oyster
#

I think I'm just googling all the wrong phrases, but w.r.t. the serial chip (e.g. FT232RL on Arduino Nano), what is "auto reset" for?

north stream
#

Lets the software installing the firmware control the target chip's reset line by using one of the RS-232 flow control lines (generally DTR or RTS).

random oyster
#

what is the reset line used for in this case? to reset the chip when programming is finished?

north stream
#

To reset the chip to get its attention to begin programming.

random oyster
#

AHH, okay that pieces it all together for me, thanks a bunch!

native kelp
#

my arduino board doesnt want to get detected on my laptop

#

for some obscure reason

#

the board gets power

#

but windows wont show it

#

nvm

#

i reset it

#

with a button

#

aaand its gone again

native kelp
#

oh yessss

#

i fixed it

verbal herald
#

hi all, just got given an Arduino Uno. Is it possible to load Circuitpython onto it?

inland crag
#

no

frank linden
#

Has anyone had experience/success using an ItsyBitsy M4, or any M4 based board, as a I2C slave? I’m attempting to use with a Raspberry Pi master in the final project however, right now I am just using it with an Uno master and M4 slave configuration with a level shifter. If it would be easier to use UART or SPI, I am open to using any, I just know how to use I2C between Pi and Arduino. Any help would be appreciated, thanks in advance.

north stream
#

AdaFruit's "Seesaw" operates with an M0 as an I2C slave, it might be worth looking at the source code.

frank linden
#

Thank you, I'll look into it, this is my first time really digging into source code so hoping for the best.

north stream
#

There are a few Arduino I2C slave libraries out there, I don't know how well any of them work, however.

frank linden
#

That's the problem I am encountering, a lot of the AVR based libraries don't really work too well on ARM stuff (from what I can tell and experience, I am no expert by any means).

frank linden
#

I also may give serial a go, as the M4 seems to be more tuned to that sort of thing, while trying to sort I2C out on the side.

harsh wedge
#

Hey guys, I have a simple electronics project where I'm controlling the USB connection of a device by hacking a USB switch and using an arduino to switch "between" USB devices. The switch is "intelligent" in a couple ways:

  1. it's powered by the USB devices connected to it
  2. it only switches if it detects two USB devices

What I'm wondering, since I don't want two devices to be plugged into the switch, is if it's possible to bridge one of the USB ports so that the switch is tricked into thinking it's always plugged in, even when it isn't. Can I just connect 5v and gnd? Everything is 5v (not sure about amps). I just want this part of the circuit to be constantly connected

humble anchor
#

@harsh wedge It is not as easy as it might seem, what type of device is it?

#

You can also try a raspberry Pi zero. The pi zero can act as a USB slave device

harsh wedge
#

good to know

#

the Pi Zero would definitely be a better setup lol

#

I just need to control a single USB port.

#

pretty much, we have a laser cutter which we want to turn on/off programmatically. Cutting power completely is overkill, so we just want to control the USB connection.

#

We have this USB switch we hacked that we can control via an Arduino now by reading an LED on the circuit

#

For our minimum viable product I want to bridge one of the USB ports since the switch is "intelligent" and will only switch if it detects a current on the port

#

I was hoping I could just connect the 5v and GND pin to trick the microcontroller on the switch into thinking a device is plugged in when it isn't

#

That being said, with the Pi Zero I need to put the device between the USB connection of the computer and the laser cutter; would that be possible?

humble anchor
#

What is the type of usb interface with the laser cutter?

#

Is it a type of usb to serial interface?

harsh wedge
#

@humble anchor upon further inspection I don't think either of those solutions will work. I can already control everything via my current setup, but wondering electrically what I'd need to be careful of. worst case I'll just keep another device plugged in to that USB and still be able to switch between them. Something must happen to trigger the USB as connected to the port on the switch as well, and I think this is a detection of electrical contact

#

hmm

#

tbh I'm not sure 😛

#

The reason we went with the switch as well is that we didn't want to cause conflicts with whatever USB does above the hardware level (low-level code) to initiate a connection. Not sure if there's logic there but wanted to be sure so our users don't run into issues

#

My first idea was just to turn on/off the 5V of the USB, but there's data lines as well, so even if the 5V was turned off the data lines would still transmit data

#

which means the laser cutter would theoretically still work even if 5V is off

north stream
#

Turning off the laser cutter is easy enough, once you know what turns it off. The rest of it, it sounds like you're making it more complicated than it needs to be.

#

Note: bridging +5 and ground is NOT what you want to do.

harsh wedge
#

good good

#

so the switch only switches if two devices are connected (I'll post a pic)

#

I'd like to be able to only have one device connected but still switch

#

therefore I want to trick one of the USB ports into being in a connected state even though it isn't. I'm all for simplicity 😄

#

I can just post here now, sorry for the duplication

#

Each port in red has to be connected to a device in order to switch between them

north stream
#

I don't understand. How can you switch if only one device is connected?

#

What are you really trying to accomplish?

harsh wedge
#

Well really I just want to be able to control the USB connection to the lasercutter. But it's been a winding path of learning the data lines need to be severed and thinking about how to do it safely that we got to using this USB switch.

#

I was hoping I could trick the switch into thinking two devices are connected by having one port connected to a device, and creating an electrical contact on the other port which tricks the switch into thinking a device is plugged into it

north stream
#

When you say "control the USB connection to the laser cutter", you actually mean turn the laser cutter on and off via its USB port?

#

Why do you want to trick the switch?

harsh wedge
#

then I don't have to have another device plugged into it.

#

Since this will be in an enclosure

north stream
#

Will the switch cut over if two devices are connected? Does it have a priority?

harsh wedge
#

I believe it leaves it on whichever device was last plugged in, since it's powered by that last device

#

That being said, our code controls which device it's on, so after some microseconds it switches to whichever port we need it on.

north stream
#

If that's true, you can turn the laser cutter off but not back on.

harsh wedge
#

hmm

#

good point

#

Well the laser cutter is always establishing a connection

north stream
#

Whn you say your code controls which device it's on, do you mean a) your code controls what the switch does, b), your code controls whatever is connected to the switch, or c) something else?

harsh wedge
#

Our code controls it via Arduino GPIO

north stream
#

The laser cutter is always establishing a connection, meaning what? Even if it's off?

harsh wedge
#

I'd like to assume it's just always on

north stream
#

You code controls what via Arduino GPIO? The switch? The laser cutter? Something else?

harsh wedge
#

The switch

#

Arduino is basically an interface to the switch

north stream
#

If it's always on, why do you want to turn it off? I'm sorry I am totally failing to follow what your situation is, what you're trying to do, and how you're trying to do it. I suspect there's a simple answer, but I'm unable to find it.

harsh wedge
#

Yeah so the reasoning is for access control

#

We have a system which authenticates and authorizes users for equipment access

#

So when access is granted, we switch to the USB port which is connected to the laser cutter

#

Otherwise (if needed we switch to ) we stay on the port not connected to the laser cutter

#

The laser cutter may be on

#

But we're controlling the USB connection to it

#

Meaning the laser cutter can't receive instructions for a print if the USB for it isn't connected to the computer

#

Basically that's a lot of background, but all I really want to do is see if I can create electrical contact on a single USB port which is equivalent to a device being plugged into that port for the rest of the circuit

#

So I was hoping I could just bridge a connection in some way to do this.

#

Since all of this is going into an enclosure

#

er, yeah I guess I'd need something on the other side to actually make this work...

#

In that case I'd just need to make the simplest USB circuit, or keep something else plugged in there. Any ideas?

north stream
#

The easiest approach might be to interrupt the power lead from the laser cutter to the switch.

harsh wedge
#

you mean the 5v?

north stream
#

Yeah. I'm guessing if the switch is unpowered, it won't transmit any data.

harsh wedge
#

actually, that's a good point

#

I hadn't thought about the laser cutter and switch in tandem

#

On its own, cutting the 5v to the laser cutter doesn't work, as the D+/D- still transmit data

#

But the switch might need power to operate

#

Though if it gets power on the other side this won't work; it's worth a try

north stream
#

Yeah, the laser cutter probably ignores 5V on the USB since it has its own power supply.

harsh wedge
#

good to know!

#

So our ultimate goal would be to make a better solution that isn't based off a hack

north stream
#

So I'm altering my suggestion: instead of interrupting the power lead from the laser cutter to the switch, interrupt the power lead from the computer to the switch.

harsh wedge
#

hmm, but the switch would still be powered?

#

by the lasercutter

north stream
#

I'm guessing the switch is powered by the computer (it should not be powered by the laser cutter, but perhaps it is). Easy enough to test by unplugging each lead.

harsh wedge
#

yeah in our testing it's powered by whatever is plugged into those two ports and possibly the one connected to the computer as well

north stream
#

Sloppy design. So cut the power traces in both locations, and have the Arduino switch the power from the computer side.

harsh wedge
#

interesting

north stream
#

Alternatively, just have the Arduino switch power into the remaining USB connector to avoid having to tack wires onto the PCB.

harsh wedge
#

ahh okay I get what you're saying

#

do you have any idea of what the usb port would be sending back to one of the ports outlined in red on the switch?

#

Not in terms of data, but current

#

er kinda same thing but you get what I'm saying

#

I have a potential solution for controlling power, but I'm also interested in learning about how the USB is actually being recognized by the microcontroller on the switch

#

by potential I mean it works, but I might make a mistake 😄

#

those ports outlined in red are supposed to be connected to computers, as this is intended to be a USB switch for a single device to use on two different computers

#

thanks for the help 😄

north stream
#

Oh, I wonder if it works the other way then. Have you tested that?

#

I'm guessing the microcontroller on the switch is monitoring the data leads and probably spoofing some of the negotiation so that the computers don't see the device disconnect and reconnect every time it switches.

harsh wedge
#

hmm, possibly. for the one I use at home though I do think it switches as I hear the familiar connect/disconnect sounds in windows

#

when you say the other way around...?

north stream
#

The other way around, with 2 devices and one computer instead of two computers and one device.

harsh wedge
#

ahh

#

we're actually testing with a battery charger for a phone

north stream
#

Sounds like it's a real simple-minded device. Maybe just using MOSFETs to switch the data leads and doing something trivial to detect when to switch.

harsh wedge
#

hmm

#

Actually to detect when to switch

#

There's an led on the switch

#

We just read that value in to determine which port the switch is on

north stream
#

Oh, I thought you wanted to know how the switch determined when to switch. How do you get the LED value back to the Arduino? Photocell?

harsh wedge
#

actually we just took the led off 😄

#

and read the current on GPIO

#

er voltage. not great with electronics yet haha

north stream
#

Heh, that won't do much good when it's powered off, but since the Arduino will be controlling it anyway, it doesn't really matter.

harsh wedge
#

the code is deceptively simple:

int relay = digitalRead(relayPin);
  int usbDetect = digitalRead(usbDetectPin);
  if ( (relay && !usbDetect ) || (!relay && usbDetect) ) {
    pressButton();
  }
  Serial.println("RELAY: " + (String)relay + " USB: " + (String)usbDetect);
#

yeah when it's off, the arduino either wants to constantly switch it, or do nothing lol

#

this code just switches the port when it detects the relay and port aren't the same value (that's the way we have it setup with wiring, at least)

north stream
#

press button? The arduino is (virtually) pressing a button on the switch? I thought it was autoswitching. How are you doing the button press? Transistor? Relay?

harsh wedge
#

yeah! GPIO

#

Arduino is acting as a complete interface to the switch

#

well, there's actually two LEDs on the switch but we only need to read one to know the state of the other

north stream
#

Not really, but it doesn't matter anyway.

harsh wedge
#

lol I like to think so. It can read and control all behaviors on the switch

#

at least the ones we need.

north stream
#

Apparently not, or you wouldn't have this problem

harsh wedge
#

lol

#

That's the logic of the switch though

#

Interface still works as intended 😉

north stream
#

Oh, you got it fixed? Cool. That was fast.

harsh wedge
#

such is the issue with hacking I guess ¯_(ツ)_/¯

#

haha

#

I do appreciate your input. pretty helpful

#

I haven't done a lot of arduino so I feel like this is ambitious

#

at this point just happy to be able to partially control the switch

#

further hacking I would hope mean more control. Really glad I asked about the bridging

#

I literally didn't think it would be an issue

harsh wedge
#

so funnily enough I started looking at an old adafruit project I remembered, MintyBoost, and in the info I found there might be a way for me to put the USB port into a state where the switch's microcontroller detects there's a device by throwing 3 V onto the D+/D- pins, which the microcontroller interprets as "no computer is attached but there is power". Will have to see if this does anything, but theoretically all I'd need is the arduino's 3.3 V pins to send the signal. https://learn.adafruit.com/minty-boost/icharging#first-attempt-14-9

Adafruit Learning System

Small battery-powered USB charger

north kelp
#

@harsh wedge I read the use case above. Even as I love making hardware, I'd be inclined to approach your problem by granting/restricting access to the laser cutter via software.

harsh wedge
#

Thanks for your input! Do you have any recommendations for approaching it via software?

#

One of our previous ideas was to restrict access via logins, but it'd requires standing up a sub-tenant inside our campus' AD

#

or sub tree or forest or whatever.

north kelp
harsh wedge
#

Yeah actually I've done that before on our home network. It's a good idea but it adds unnecessary complexity to our existing infrastructure. If this doesn't work we'd probably use CUPS authentication. But what we have right now is an RFID reader as part of a SaaS called Fabman which allows students to tap their cards to auth

north kelp
#

Are students physically plugging/unplugging a USB cable to access the printer?

harsh wedge
#

This project has given me all sorts of ideas though, like being able to use an Arduino to wait for a keypress to switch KVM, or potentially routing USB through another medium. I'd need to read up on a lot to learn but yeah happy learning lol

#

Nope

#

That'll be locked up

#

Which is why we're programmatically controlling whether it's "plugged in" or not

barren scaffold
#

Is the goal to make a print release station for students?

harsh wedge
#

It's access control to equipment