Sparkswitch + UART and nrf modules on 1 pcb (Arduino Compatible)

“Remember that HM10 TX goes to ATMEGA RX and HM10 RX goes to ATMEGA TX” Not always. If you use SoftwareSerial you can have it on which ever pin you want. And the ATMEGA TX and RX I use for the VESC data. So you can get voltage, ampere etc. But I havent made a path of it in the circuit yet. Thanks for reminding me :wink:

Here is an example of using SoftwareSerial(Its how I use the HM-10 Bluetooth):

include “SoftwareSerial.h” include “SPI.h” SoftwareSerial mySerial(7, 8);

void setup(){ mySerial.begin(9600); }

void bluetooth() {

while (mySerial.available()) { char c = mySerial.read();

textString += c;

if (textString == "CLR:")
{
  bColor = true;
  textString = "";
}

if (bColor == true)
{
  //Serial.print(textString);
  if (textString == "CR") {
    cRed = true;
    textString = "";
  }

  if (textString == "CB") {
    cBlue = true;
    textString = "";
  }

  if (textString == "CG") {
    cGreen = true;
    textString = "";
  }

  if (cRed) {
    if (c == ',') {
      int txtstringLength = textString.length();
      textString.remove(txtstringLength - 1);
      red = textString.toInt();
      textString = "";
      cRed = false;
    }
  }

  if (cGreen) {
    if (c == ',') {
      int txtstringLength = textString.length();
      textString.remove(txtstringLength - 1);
      green = textString.toInt();
      textString = "";
      cGreen = false;
    }
  }

  if (cBlue) {
    if (c == ',') {
      int txtstringLength = textString.length();
      textString.remove(txtstringLength - 1);
      blue = textString.toInt();
      textString = "";
      allPixels(red, green, blue);
      if (bLights) {
        pixels.show();
      }
      cBlue = false;
    }
  }
}

if (c == '.') {
  bColor = false;
  //Serial.println(textString);
  recievedMessage(textString);
  textString = "";
}

} lightMode(lMode); }

But that is for softwareserial. The vesc needs it that way.

No, the VESC is using the Serial also the TX and RX is the Serial.

Oh ok. Whatever you think… I would wire rx to tx and tx to rx since that is what everyone does.

I think you are misunderstanding me or I am not clear.

There is a library called SoftwareSerial for the ATMEGA. It allows you to connect and communitcate with multiple communication ports. So you set it up with ex. mySerial(tx, rx);. You can choose whatever pin you want! The UART of the VESC only works with the SERIAL that is pin 0 and 1! Because of the way that code is written. I will probably rewrite it because I like to have the Serial in not use so you can debug. with the Serial Monitor.

So you are talking about the VESC? Im talking about the bluetooth.

With the VESC its RX and TX on ATMEGA because of the way its written. But I would much more prefer SoftwareSerial so its easier to see whats happening. And fixing bugs.

I have no idea of what you are saying. Please send a picture of yourschematic of your pcb to me via PM so I can look at it and understand what you mean. I am talking about the wiring from atmega to hm10 and if I look at your schematic I can confirm what I mean.

I have no schematics… But I can create one now.

And it get the power from the UART too because its 3 volt there and 5v. So I dont really need to have a 3v3 regulator

hey this is really cool! I just finished soldering a couple nano + nrf with pins for lights and whatever and it was a pain! takes for ever to get all the connections.

I’m not sure it makes any sense to put the spark switch on the same board tho. that thing will have lots of current going through it, if something fries the rest of the circuit is kinda lost too…

blue tooth is nice, but maybe add a cuttoff switch? it can be hacked if someone really wanted too. not fun!

You are right. But I don’t think the sparkswitch wont be a problem. But I was creating this for my board, but then people suddenly got interested :3 So I am making it public. Yes I can add a switch you can turn the power of the bluetooth.

And to point it out the bluetooth has passwor.

well there have been a few reports of spark switches going bust recently. I just think the wireless module on its own would be much better. I want a few of those if you cut the pcb in half. or maybe i’ll finally learn eaglecad!

oh and passwords can be broken in a few minutes now…

Yeah, the bluetooth password can be broken easily btw Im using Circuit Maker http://circuitmaker.com/ the Eagle Cad is probably better :wink:

About the wireless, you will need another NRF24L01 with an Arduino bootloader that is running it with the same setup with the package sending.

Yea i’m using a couple of these for tx/rx but no bt since i’m just controlling with ppm for now. I can use the regular serial pins on the vesc for bt separately.

Still working on the code, i’m going to open source it soon, but that hardware would save me time for the next ones.

Awesome controller! I can provide you with my hardware if it will help xD

I added where you can add a switch that turns the power of the HM-10 on and off, beside the “T R” for TX and RX of the ATMEGA. That is where you connect to the VESC for data. the + L - is for neopixel lights. - + P is the ground input 5v input and the pulse output for controlling the speed of the vesc.

Added if you just want it to be separated you can just saw it off.

thanks I need to print out a case and it will be ready for some real tests!

I need to learn pcb design, a custom board will make it so much smaller. but hard to argue with $3 nano clones… $1 rf module and a couple hours of soldering.

why not break out a few more pwm/analog pins? just to make it more flexible! I could see other uses for this! right now mine is controlling a mini robot.

Will do :slight_smile: But I will keep making it tomorrow because its late here time for bed. Good night![quote=“saul, post:36, topic:14608”] I need to learn pcb design, a custom board will make it so much smaller. but hard to argue with $3 nano clones… $1 rf module and a couple hours of soldering. [/quote]

Mhmm from oshpark you get this pcb with the vedders switch for 15 dollar for 3 pieces. And the Atmega around 0.9 dollar, same with the SMD nrfl24l01, and the crystal is very cheap too, but you will need 22uf for the crystal etc. But I can make it home and ship it. But that wont be before I am finished with this circuit etc. So this custom circuit will cost around 10 dollars(IF you dont want to have the switch spark because the transistors on it, is a bit expensive). Not bad for beeing a custom :stuck_out_tongue:

What I mean with the 10 dollar price is. IF its without the top piece(vedders switch) ATMEGA328P-AU, can be found for 0.9 piece NRF24L01 smd 1 dollar Crystal <1dollar Custom circuit for 3 = 15 / 3 = 5

5 + 3 = >9 Dollar.

There are no protection of over voltage! So if you are gonna use it with batteries but not with the VESC then you need a 5 VOLT battery. Because the 3.3 Regulator only works from 4.5v → 7v. And the ATMEGA328P-AU Chip only operate from 1.5v → 5.5v So I think I shall add that you can have +12v because that would be handy. But that will wait for tomorrow

You might as well just put the VESC on there while you are at it lol.

Haha! I was planning on making a motherboard for my eboard. Also all in one pcb. Li-ion Bms 12S charging, 2 VESC, Vedders Switch, and the hardware I use(ATMEGA, NRF24L01, BT and the Neopixel Lights).

But recreating the VESC takes a lot of time and I saw the VESCX has alot less components then the VESC.

Well maybe after christmas I will create a motherboard for my eboard :stuck_out_tongue:

This save time cutting wires and soldering, plus its much more compact so its worth it!! no rush! my prototype boards will work fine for testing the software.