If you are spending some time in São Paulo and want to get to Campinas you should take the Metro (blue line) to Estação Tiete, one of the Central Bus Stations in São Paulo. There you can take a bus to Campinas. There is no need to buy tickets in advance, there are coaches leaving every 10 or 15 minutes. It takes one and a half hour to get to Campinas' Central Bus Station, where you can take a bus to Barão Geraldo (bus line 332 will do it).
An alternative is to register at a to share a trip to Campinas. Look for trips to Barão Geraldo, there are many, specially on Sunday evening and Monday morning. It takes about half the time and half the price.